package com.handinfo.android.ui.window;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Pattern;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.net.GameProtocol;
import com.handinfo.android.core.object.Actor;
import com.handinfo.android.core.object.Animation;
import com.handinfo.android.game.Attribute;
import com.handinfo.android.game.Cell;
import com.handinfo.android.game.GameMessage;
import com.handinfo.android.game.IconManger;
import com.handinfo.android.game.item.DuanZao;
import com.handinfo.android.game.item.Item;
import com.handinfo.android.game.item.ItemConstants;
import com.handinfo.android.game.item.ItemEquipment;
import com.handinfo.android.game.item.ItemGem;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWControlTools;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWAnimationBox;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWCheckbox;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWGrid;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWInputBox;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWMessageBox;
import com.handinfo.android.uicontrols.controls.DWPopMenu;
import com.handinfo.android.uicontrols.controls.DWTabControl;
import com.handinfo.android.uicontrols.controls.DWTabPage;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

/**
 * 
 * 天工坊
 * 
 * @author mujianchen
 * 
 */

public class UITianGong implements IUIWindows
{
	public DWFrame m_tgFrame = null;
	public DWTitle m_tgTitle = null;

	public Bitmap m_tgBitmap01 = null;
	public Bitmap m_tgBitmap02 = null;
	public Bitmap m_tgBitmap04 = null;
	public Bitmap m_tgBitmap04_ax = null;
	public Bitmap m_tgBitmap_BT = null;//标题
	public Bitmap m_tgBitmapTab01 = null;//标签页图片01
	public Bitmap m_tgBitmapTab02 = null;//标签页图片02
	public Bitmap m_tgBitmap11 = null;//grid背包格
	public Bitmap[] m_tgBitmap12 = new Bitmap[5];//小图片集合

	public Bitmap m_fy_left = null;//左
	public Bitmap m_fy_right = null;//右

	public DWImageBox m_tgImageBox01 = null;
	public DWImageBox m_tgImageBox02 = null;
	public DWImageBox m_tgImageBox03 = null;
	public DWImageBox m_tgImageBox_BT = null;//标题

	public DWBackground[] m_tgBackground01 = new DWBackground[4];//背景集合

	//身上装备图标
	public Bitmap m_Bitmap_ZB = null;

	//标签页
	public DWTabControl m_tgTabControl01 = null;
	public DWTabPage m_tgTabPage01 = null;
	public DWTabPage m_tgTabPage02 = null;
	public DWTabPage m_tgTabPage03 = null;
	public DWTabPage m_tgTabPage04 = null;
	public DWTabPage m_tgTabPage05 = null;
	public String m_tgString[] = { "装备熔炼", "装备强化", "灵石镶嵌", "灵石合成", "装备锻造" };

	//装备熔炼
	public DWTextbox m_tgLabel01 = null;
	public DWTextbox m_tgLabel05 = null;
	public DWTextbox m_tgTextbox01 = null;
	public DWTextbox m_tgTextbox04 = null;
	public DWTextbox m_tgTextbox05 = null;
	public DWBackground m_tgBackground04 = null;
	public Bitmap m_tgBitmap_RL = null;
	public DWImageBox m_tgImageBox_RL = null;
	public DWGrid[] m_tgGrid_RL01 = new DWGrid[5];//熔炼显示框
	public DWButton m_tgButton01 = null;
	public DWListbox m_tgListbox_RongLianCao = null;//熔炼装备槽
	public DWListbox m_tgListbox_HuanCunCao = null;//熔炼缓存槽
	public int m_tgIndex01 = 0;
	public DWImageBox m_tgImageBox_JH = null;

	//装备强化
	public DWTextbox m_tgLabel02 = null;
	public DWTextbox m_tgLabel06 = null;
	public DWTextbox m_tgTextbox06 = null;
	public DWTextbox m_tgTextbox07 = null;
	public DWTextbox m_tgTextbox08 = null;
	public DWTextbox m_tgTextbox09 = null;
	public DWTextbox m_tgTextbox10 = null;
	public DWTextbox m_tgTextbox15 = null;
	public DWTextbox m_tgTextbox_maxLevel = null;
	public DWTextbox[] m_qh_tgTextbox31 = new DWTextbox[8];//装备强化属性显示
	public DWTextbox m_tgTextbox18 = null;
	public DWButton m_tgButton02 = null;
	public DWButton m_tgButton03 = null;
	public DWBackground m_tgBackground06 = null;
	public DWGrid m_tgGrid03 = null;
	public DWImageBox m_tgImageBox04 = null;
	public DWTextbox m_tgTextbox_MAXLEVEL = null;
	public DWListbox m_tgListbox_QiangHua = null;
	public int m_tgIndex02 = 0;
	public DWListbox m_tgListbox_qh01 = null;

	//灵石镶嵌
	public DWTextbox m_tgLabel03 = null;
	public DWTextbox m_tgLabel07 = null;
	public DWBackground m_tgBackground07 = null;
	public DWTextbox m_tgTextbox11 = null;
	public DWTextbox m_tgTextbox12 = null;
	public DWTextbox m_tgTextbox19 = null;
	public DWTextbox[] m_tgTextbox_BSMS = new DWTextbox[4];//宝石描述
	public DWButton m_tgButton06 = null;
	public DWGrid m_tgGrid04 = null;
	public DWGrid[] m_tgGrid05 = new DWGrid[4];//宝石格子
	public DWImageBox[] m_tgImageBox_DH_XQ = new DWImageBox[4];
	public DWImageBox[] m_tgImageBox08 = new DWImageBox[4];//宝石格子外框
	public DWListbox m_tgListbox_XiangQian = null;
	public int m_tgIndex03 = 0;
	public Bitmap[] m_tgBitmap23 = new Bitmap[4];
	public DWPopMenu m_tgPopMenu01 = null;

	//灵石合成
	public DWTextbox m_tgLabel04 = null;
	public DWTextbox m_tgLabel08 = null;
	public DWBackground m_tgBackground08 = null;
	public DWTextbox m_tgTextbox13 = null;
	public DWTextbox m_tgTextbox14 = null;
	public DWTextbox m_tgTextbox20 = null;
	public DWButton m_tgButton07 = null;
	public DWButton m_tgButton08 = null;
	public DWGrid m_tgGrid09 = null;
	public DWImageBox m_tgImageBox_DH_HC = null;
	public DWGrid[] m_tgGrid10 = new DWGrid[3];
	public DWImageBox m_tgImageBox05 = null;
	public DWImageBox m_tgImageBox06 = null;
	public DWImageBox m_tgImageBox07 = null;
	public DWListbox m_tgListbox_HeCheng = null;
	public int m_tgIndex04 = 0;

	//装备锻造
	public DWListbox m_tgListbox_DuanZao = null;
	public DWTextbox m_dzTextbox01 = null;
	public DWTextbox m_dzTextbox02 = null;
	public DWBackground m_dzBackground01 = null;
	public DWGrid m_dzGrid_ZhuangBei = null;//装备grid
	public DWGrid m_dzGrid_Copy = null;//对齐所需
	public DWGrid m_dzGrid_ZhuangBei_next = null;//下一级装备
	public DWGrid m_dzGrid_CaiLiao01 = null;
	public DWGrid m_dzGrid_CaiLiao02 = null;
	public DWGrid m_dzGrid_BaoHu = null;
	public DWImageBox m_dzImageBox_JianTou = null;
	public int m_dzIndex_DuanZao = 0;
	public DWTextbox m_dzTextbox_TiShi = null;
	public DWButton m_dzButton_DuanZao = null;
	public Bitmap m_dzBitmap_DuanZao = null;
	public Bitmap m_dzBitmap_DuanZao_ax = null;
	public Bitmap m_dzBitmap_Suo = null;
	public boolean m_dzBaoHuFu_index;
	public DWTextbox m_dzTextbox_num01 = null;
	public DWTextbox m_dzTextbox_num02 = null;
	public DWTextbox m_dzTextbox_TiShiBHF = null;
	public int m_dzGrid_x = 0;//装备格子横移坐标
	public boolean m_dzHengYi_x;
	public int m_dzQiangHuaLevel = 0;
	public Actor m_jiantou_Actor = null;//箭头动画
	public DWAnimationBox m_animBox_jiantou = null;
	public Actor m_duanzao_Actor = null;//锻造按钮动画
	public DWAnimationBox m_animBox_duanzao = null;
	public Actor m_star_Actor = null;//锻造道具动画
	public DWAnimationBox m_animBox_star = null;
	public Actor m_daoju_Actor = null;//锻造道具动画
	public DWAnimationBox m_animBox_daoju = null;
	public DWTextbox m_dzTextbox_level = null;//等级限制

	//灵石合成 镶嵌灵石的动画缓存
	public Cell m_AnimCatch = null;//动画缓存
	public int m_AnimIndex = -1;//动画索引
	public int m_rdtime;//间隔时间
	public final int RDTIME = 0;

	boolean m_tgXuanzhong01 = false;//选择框 默认关闭

	public Cell[] m_equip_list;//操作装备列表
	public Cell[] m_gem_list;//操作宝石列表
	public int[] m_gem_num;//宝石计数
	public Vector<Cell> m_equip_cache_list;//操作缓存列表
	public int m_tabindex;//标签索引 
	public int[] m_nextStrengthenAttrAddValue = new int[Attribute.SIZE];

	public byte tiangong_open_state = 0;

	private Bitmap[] m_tgBitmap_DH = new Bitmap[5];//动画

	public void init()
	{
		m_tgBitmap01 = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp");//关闭图片
		m_tgBitmap02 = UIWindows.createImage("/img/newui/anniu_4.gnp");//按钮图片开
		m_tgBitmap04 = UIWindows.createImage("/img/newui/anniu_1.gnp");
		m_tgBitmap04_ax = UIWindows.createImage("/img/newui/anniu_1ax.gnp");

		m_tgBitmapTab01 = UIWindows.createImage("/img/newui/biaoqianye_1.gnp");//标签页选项
		m_tgBitmapTab02 = UIWindows.createImage("/img/newui/biaoqianye_2.gnp");//标签页选项

		m_tgBitmap_BT = UIWindows.createImage("/img/newui/tiangongfang_1.gnp");

		m_tgBitmap_RL = UIWindows.createImage("/img/newui/rongzhubj_1.gnp");//装备熔炼背景炉子

		m_fy_left = UIWindows.createImage("/img/newui/haoyoufyan_2.gnp");//左翻页
		m_fy_right = UIWindows.createImage("/img/newui/haoyoufyan_1.gnp");//右翻页

		m_tgBitmap11 = UIWindows.createImage("/img/newui/wupinlan.gnp");//背包格

		m_tgBitmap12[0] = UIWindows.createImage("/img/newui/tiangongfangzbrljt_1.gnp");//箭头
		m_tgBitmap12[2] = UIWindows.createImage("/img/newui/tiangongfanglshcjt_1.gnp");//箭头黄0
		m_tgBitmap12[3] = UIWindows.createImage("/img/newui/tiangongfanglshcjt_2.gnp");//箭头黄1
		m_tgBitmap12[4] = UIWindows.createImage("/img/newui/tiangongfanglshcjt_3.gnp");//箭头黄2

		//镶嵌宝石位
		m_tgBitmap23[0] = IconManger.getInstance().getPinzhi(6);//红
		m_tgBitmap23[1] = IconManger.getInstance().getPinzhi(2);//蓝
		m_tgBitmap23[2] = IconManger.getInstance().getPinzhi(3);//绿
		m_tgBitmap23[3] = IconManger.getInstance().getPinzhi(5);//黄

		//动画
		m_tgBitmap_DH[0] = UIWindows.createImage("/img/newui/xuanzhongdonghua_0.gnp");
		m_tgBitmap_DH[1] = UIWindows.createImage("/img/newui/xuanzhongdonghua_1.gnp");
		m_tgBitmap_DH[2] = UIWindows.createImage("/img/newui/xuanzhongdonghua_2.gnp");
		m_tgBitmap_DH[3] = UIWindows.createImage("/img/newui/xuanzhongdonghua_3.gnp");
		m_tgBitmap_DH[4] = UIWindows.createImage("/img/newui/xuanzhongdonghua_4.gnp");

		//身上装备图标
		m_Bitmap_ZB = UIWindows.createImage("/img/newui/tiangongfangxyf_1.gnp");

		m_dzBitmap_DuanZao = UIWindows.createImage("/img/newui/duanzao_1.gnp");//锻造按钮
		m_dzBitmap_DuanZao_ax = UIWindows.createImage("/img/newui/duanzao_2.gnp");//锻造按钮按下
		m_dzBitmap_Suo = UIWindows.createImage("/img/newui/beibaost_1.gnp");//网格锁

		Animation jiantou = UIWindows.createAnimation("/anim/duanzao_jiantou.anim");
		m_jiantou_Actor = new Actor(jiantou);

		Animation duanzao_button = UIWindows.createAnimation("/anim/duanzao_anniu.anim");
		m_duanzao_Actor = new Actor(duanzao_button);

		Animation duanzao_star = UIWindows.createAnimation("/anim/duanzao_start.anim");
		m_star_Actor = new Actor(duanzao_star);

		Animation duanzao_daoju = UIWindows.createAnimation("/anim/duanzao_tubiaoguangyun.anim");
		m_daoju_Actor = new Actor(duanzao_daoju);
	}

	public void updata()
	{
		m_tabindex = 0;
		if (m_equip_cache_list == null) {
			m_equip_cache_list = new Vector<Cell>();
		}
		else {
			m_equip_cache_list.clear();
		}
		refreshEquipList(m_tabindex);
		refreshGemList();
	}

	public void tiangong()
	{
		m_flag_ronglian = true;
		if (m_tgFrame != null) {
			DWControlsManager.getInstance().removeControl(m_tgFrame);
		}
		m_tgFrame = new DWFrame(DWFrame.FRAME_TYPE_FULL, true);
		m_tgFrame.setClickClose(false);
		m_tgTitle = new DWTitle(null, m_tgFrame);

		m_tgImageBox_BT = new DWImageBox(m_tgBitmap_BT);
		m_tgImageBox_BT.setNearAnchor(m_tgTitle, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

		m_tgImageBox01 = new DWImageBox(m_tgBitmap01);
		m_tgImageBox01.addListener(m_back_lis);
		m_tgImageBox01.setNearAnchor(m_tgTitle, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER);
		m_tgImageBox01.setTouchZoomIn(20, 20);

		m_tgBackground01[0] = new DWBackground(m_tgFrame.getShowWidth() - 40, m_tgFrame
				.getShowHeight() - 60);
		m_tgBackground01[0].setNearAnchor(m_tgFrame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);

		m_tgBackground01[1] = new DWBackground(0, 0, m_tgFrame.getShowWidth() / 7 * 4 + 20,
				m_tgFrame.getShowHeight() - 115);
		m_tgBackground01[1]
				.setNearAnchor(m_tgTitle, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 20, m_tgBitmapTab01.getHeight());

		m_tgBackground01[2] = new DWBackground(0, 0, m_tgFrame.getShowWidth() / 7 * 3 - 50,
				m_tgFrame.getShowHeight() - 115);
		m_tgBackground01[2].setNearAnchor(m_tgTitle, Tools.RIGHT_TOP, Tools.RIGHT_BOTTOM, -20, m_tgBitmapTab01
				.getHeight());

		m_tgTabControl01 = new DWTabControl(m_tgBitmapTab01, m_tgBitmapTab02, m_tgFrame.getShowWidth() - 20,
				m_tgFrame.getShowHeight() - 20);
		m_tgTabControl01.setNearAnchor(m_tgTitle, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);

		m_tgTabControl01.addListener(new DWListener() {

			public void OnDoubleClick()
			{

			}

			public void OnClick()
			{
				int index = m_tgTabControl01.getPageIndex();
				if (index == m_tabindex) {
					return;
				}
				m_tabindex = index;
				switch (index)
				{
					case 0:
						tiangong_open_state = 0;
						refreshEquipList(index);
						if (m_tgListbox_RongLianCao != null) {
							m_tgListbox_RongLianCao.removeAllSubItem();
							listbox_RongLian();
						}
						refreshText();
						refreshListbox_QiangHua();
						refreshListbox_XiangQian();
						refreshListbox_XiangQianBaoShi();
						refreshListbox_HeCheng();
						refreshListbox_DuanZao();
						delCacheList();
						break;
					case 1:
						tiangong_open_state = 1;
						refreshEquipList(index);
						if (m_tgListbox_QiangHua != null) {
							m_tgListbox_QiangHua.removeAllSubItem();
							listbox_QiangHua();
						}
						refreshText();
						refreshListbox_RongLian();
						refreshListbox_XiangQian();
						refreshListbox_XiangQianBaoShi();
						refreshListbox_HeCheng();
						refreshListbox_DuanZao();
						delCacheList();
						break;
					case 2:
						tiangong_open_state = 2;
						refreshEquipList(index);
						if (m_tgListbox_XiangQian != null) {
							m_tgListbox_XiangQian.removeAllSubItem();
							listbox_XiangQian();
						}
						if (m_listbox_LingShiList != null) {
							m_listbox_LingShiList.removeAllSubItem();
							listbox_LingShiList();
						}
						refreshText();
						refreshListbox_RongLian();
						refreshListbox_QiangHua();
						refreshListbox_HeCheng();
						refreshListbox_DuanZao();
						delCacheList();
						break;
					case 3:
						tiangong_open_state = 3;
						refreshGemList();
						if (m_tgListbox_HeCheng != null) {
							m_tgListbox_HeCheng.removeAllSubItem();
							listbox_HeCheng();
						}
						refreshText();
						refreshListbox_RongLian();
						refreshListbox_QiangHua();
						refreshListbox_XiangQian();
						refreshListbox_XiangQianBaoShi();
						refreshListbox_DuanZao();
						delCacheList();
						break;
					case 4:
						tiangong_open_state = 4;
						refreshEquipList(index);
						if (m_tgListbox_DuanZao != null) {
							m_tgListbox_DuanZao.removeAllSubItem();
							listbox_DuanZao();
						}
						refreshText();
						refreshListbox_RongLian();
						refreshListbox_QiangHua();
						refreshListbox_XiangQian();
						refreshListbox_XiangQianBaoShi();
						refreshListbox_HeCheng();
						delCacheList();
						break;
				}
			}
		});

		for (int i = 0; i < 5; i++) {
			switch (i) {
				case 0:
					tiangong_open_state = 0;
					m_tgTabPage01 = new DWTabPage();
					m_tgTabPage01.setName(m_tgString[0]);
					m_tgTabControl01.addTabPage(m_tgTabPage01);

					m_tgImageBox_RL = new DWImageBox(m_tgBitmap_RL);
					m_tgImageBox_RL.setNearAnchor(m_tgTabPage01, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);

					m_tgTextbox01 = new DWTextbox("<mark c=00ffff>从右侧勾选装备进行熔炼</mark>");
					m_tgTextbox01.setNearAnchor(m_tgTabPage01, Tools.LEFT_TOP, Tools.LEFT_TOP, 40, 20);

					m_tgTextbox04 = new DWTextbox("当前精魂:" + "<mark c=FF0000>"
							+ DWGameManager.getInstance().m_role.m_jinghun + "</mark>");
					m_tgTextbox04.setNearAnchor(m_tgTabPage01, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 50, -10);

					m_tgTextbox05 = new DWTextbox("<mark c=FFBB11>熔炼可以将装备转化为精魂</mark>");
					m_tgTextbox05.setNearAnchor(m_tgTabPage01, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 50, -10);

					m_tgButton01 = new DWButton("熔炼精魂", m_tgBitmap04);
					m_tgButton01.setDownImage(m_tgBitmap04_ax);
					m_tgButton01.setNearAnchor(m_tgTabPage01, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 20, -60);
					m_tgButton01.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_equip_cache_list != null) {
								DWGameManager.getInstance().getSendMessage().sendSmeltingEquip(m_equip_cache_list);
							}
						}
					});

					m_tgGrid_RL01[0] = new DWGrid((m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70, m_tgBitmap11
							.getHeight(), m_tgBitmap11.getHeight());
					m_tgGrid_RL01[0].setNearAnchor(m_tgTabPage01, Tools.LEFT_TOP, Tools.LEFT_TOP,
							(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70);
					m_tgGrid_RL01[0].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid_RL01[0] != null && m_equip_cache_list.size() > 0) {
								UIWindows.getInstance().m_bag.showItemMessage((Item) m_tgGrid_RL01[0].m_data);
							}
						}
					});

					m_tgGrid_RL01[1] = new DWGrid((m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70, m_tgBitmap11
							.getHeight(), m_tgBitmap11.getHeight());
					m_tgGrid_RL01[1].setNearAnchor(m_tgGrid_RL01[0], Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, -10, 0);
					m_tgGrid_RL01[1].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid_RL01[1] != null && m_equip_cache_list.size() > 1) {
								UIWindows.getInstance().m_bag.showItemMessage((Item) m_tgGrid_RL01[1].m_data);
							}
						}
					});

					m_tgGrid_RL01[2] = new DWGrid((m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70, m_tgBitmap11
							.getHeight(), m_tgBitmap11.getHeight());
					m_tgGrid_RL01[2].setNearAnchor(m_tgGrid_RL01[0], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
					m_tgGrid_RL01[2].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid_RL01[2] != null && m_equip_cache_list.size() > 2) {
								UIWindows.getInstance().m_bag.showItemMessage((Item) m_tgGrid_RL01[2].m_data);
							}
						}
					});

					m_tgGrid_RL01[3] = new DWGrid((m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70, m_tgBitmap11
							.getHeight(), m_tgBitmap11.getHeight());
					m_tgGrid_RL01[3].setNearAnchor(m_tgGrid_RL01[1], Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, -10, 0);
					m_tgGrid_RL01[3].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid_RL01[3] != null && m_equip_cache_list.size() > 3) {
								UIWindows.getInstance().m_bag.showItemMessage((Item) m_tgGrid_RL01[3].m_data);
							}
						}
					});

					m_tgGrid_RL01[4] = new DWGrid((m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70, m_tgBitmap11
							.getHeight(), m_tgBitmap11.getHeight());
					m_tgGrid_RL01[4].setNearAnchor(m_tgGrid_RL01[2], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
					m_tgGrid_RL01[4].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid_RL01[4] != null && m_equip_cache_list.size() > 4) {
								UIWindows.getInstance().m_bag.showItemMessage((Item) m_tgGrid_RL01[4].m_data);
							}
						}
					});

					m_tgImageBox03 = new DWImageBox(m_tgBitmap12[0]);
					m_tgImageBox03.setNearAnchor(m_tgGrid_RL01[0], Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 80, 35);

					m_tgLabel01 = new DWTextbox("<mark c=FFBB11>装备</mark>");
					m_tgLabel05 = new DWTextbox("<mark c=FFBB11>等级</mark>");
					m_tgBackground04 = new DWBackground(0, 0, m_tgBackground01[2].getShowWidth(),
							m_tgLabel01.getShowHeight() + 10);
					m_tgBackground04.setNearAnchor(m_tgTabPage01, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 0, 60);
					m_tgTabPage01.addControls(m_tgBackground04);

					m_tgLabel01.setNearAnchor(m_tgBackground04, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 40, 0);
					m_tgLabel05.setNearAnchor(m_tgBackground04, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, -40, 0);
					m_tgTabPage01.addControls(m_tgLabel01);
					m_tgTabPage01.addControls(m_tgLabel05);

					m_tgListbox_RongLianCao = new DWListbox(m_tgBackground01[2].getShowWidth() - 20,
							m_tgFrame.getShowHeight() - 190);
					m_tgListbox_RongLianCao.setNearAnchor(m_tgTabPage01, Tools.RIGHT_TOP, Tools.RIGHT_TOP, -15, 65);
					m_tgListbox_RongLianCao.setLineSpacing(10);

					m_tgListbox_HuanCunCao = new DWListbox(140, 140);
					m_tgListbox_HuanCunCao
							.setNearAnchor(m_tgGrid_RL01[1], Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 30, 6);
					m_tgListbox_HuanCunCao.setShowBackgroundRect(false);

					m_tgTabPage01.addControls(m_tgImageBox_RL);
					m_tgTabPage01.addControls(m_tgTextbox01);
					m_tgTabPage01.addControls(m_tgTextbox04);
					m_tgTabPage01.addControls(m_tgTextbox05);
					m_tgTabPage01.addControls(m_tgButton01);
//					m_tgTabPage01.addControls(m_tgImageBox03);
					m_tgTabPage01.addControls(m_tgBackground04);
					m_tgTabPage01.addControls(m_tgLabel01);
					m_tgTabPage01.addControls(m_tgLabel05);
					for (int j = 0; j < m_tgGrid_RL01.length; j++) {
						m_tgTabPage01.addControls(m_tgGrid_RL01[j]);
					}
					m_tgTabPage01.addControls(m_tgListbox_RongLianCao);
					m_tgTabPage01.addControls(m_tgListbox_HuanCunCao);
					break;
				case 1:
					tiangong_open_state = 1;
					m_tgTabPage02 = new DWTabPage();
					m_tgTabPage02.setName(m_tgString[1]);
					m_tgTabControl01.addTabPage(m_tgTabPage02);

					m_tgTextbox06 = new DWTextbox("<mark c=00ffff>从右侧选择装备进行强化</mark>");
					m_tgTextbox06.setNearAnchor(m_tgTabPage02, Tools.LEFT_TOP, Tools.LEFT_TOP, 40, 20);

					m_tgButton02 = new DWButton("强化装备", m_tgBitmap04);
					m_tgButton02.setDownImage(m_tgBitmap04_ax);
					m_tgButton02.setNearAnchor(m_tgTabPage02, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 20, -60);
					m_tgButton02.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid03.m_data != null) {
								if (m_equip_list != null) {
									final Cell cell = m_equip_list[m_tgIndex02];
									Tools.debugPrintln("cell.name=" + cell.m_item.m_name + ";cell type="
											+ cell.m_column_type + ";cell index=" + cell.m_index);
									final ItemEquipment equip = (ItemEquipment) cell.m_item;
									if (equip.m_strengthenLevel >= equip.m_maxStrengthenLevel) {
										DWGameManager.getInstance().addSystemInfo(
												DWGameManager.SYSTEM_INFO_TYPE_B, "当前已强化到最大等级");
									}
									else {
										if (equip.m_strengthenLevel > 0) {
											final DWMessageBox mb = new DWMessageBox("提示", "将装备“"
													+ "<mark c="
													+ UIBag.getNameColor(cell.m_item.m_quality)
													+ ">"
													+ cell.m_item.m_name
													+ "</mark>"
													+ "”自"
													+ equip.getProductOrder((short) equip.m_strengthenLevel)
													+ "强化至"
													+ (equip.getProductOrder((short) (equip.m_strengthenLevel + 1)))
													+ "将消耗"
													+ "<mark c=FF0000>"
													+ m_jinghun_num
													+ "</mark>"
													+ "点精魂，是否继续？");
											mb.addListener(new DWListener() {

												public void OnDoubleClick()
												{

												}

												public void OnClick()
												{
													if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
														Tools.debugPrintln("装备强化");

														DWGameManager.getInstance().getSendMessage()
																.sendOperaterCellMenuCommand
																(GameProtocol.操作装备_强化, (byte) cell.m_column_type,
																		cell.m_index);
													}
													else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
														Tools.debugPrintln("返回");
													}
													DWControlsManager.getInstance().removeControl(mb);
												}
											});
											DWControlsManager.getInstance().addControl(mb);
										}
										else {
											final DWMessageBox mb = new DWMessageBox("提示", "将装备“"
													+ "<mark c="
													+ UIBag.getNameColor(cell.m_item.m_quality)
													+ ">"
													+ cell.m_item.m_name
													+ "</mark>"
													+ "”强化至"
													+ (equip.getProductOrder((short) (equip.m_strengthenLevel + 1)))
													+ "将消耗"
													+ "<mark c=FF0000>"
													+ m_jinghun_num
													+ "</mark>"
													+ "点精魂，是否继续？");
											mb.addListener(new DWListener() {

												public void OnDoubleClick()
												{

												}

												public void OnClick()
												{
													if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
														Tools.debugPrintln("装备强化");

														DWGameManager.getInstance().getSendMessage()
																.sendOperaterCellMenuCommand
																(GameProtocol.操作装备_强化, (byte) cell.m_column_type,
																		cell.m_index);
													}
													else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
														Tools.debugPrintln("返回");
													}
													DWControlsManager.getInstance().removeControl(mb);
												}
											});
											DWControlsManager.getInstance().addControl(mb);
										}
									}
								}
							}
							else {
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"请先选择一件装备");
							}
						}
					});

					m_tgButton03 = new DWButton("精魂抽取", m_tgBitmap04);
					m_tgButton03.setDownImage(m_tgBitmap04_ax);
					m_tgButton03.setNearAnchor(m_tgButton02, Tools.LEFT_TOP, Tools.RIGHT_TOP, 23, 0);
					m_tgButton03.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid03.m_data != null) {
								DWGameManager.getInstance().getSendMessage().sendExtractionSpiritNum(
										m_equip_list[m_tgIndex02].m_item.m_guid);
							}
							else {
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"请先选择一件装备");
							}
						}
					});

					m_tgTextbox07 = new DWTextbox("当前精魂:" + "<mark c=FF0000>"
							+ DWGameManager.getInstance().m_role.m_jinghun + "</mark>");
					m_tgTextbox07.setNearAnchor(m_tgTabPage02, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 50, -10);

					m_tgTextbox08 = new DWTextbox("<mark c=FFBB11>使用熔炼的精魂可以强化装备属性</mark>");
					m_tgTextbox08.setNearAnchor(m_tgTabPage02, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 50, -10);

					m_tgTextbox15 = new DWTextbox(null);
					m_tgTextbox15.setNearAnchor(m_tgButton03, Tools.LEFT_TOP, Tools.RIGHT_TOP, 30, 40);

					m_tgGrid03 = new DWGrid((m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70, m_tgBitmap11
							.getHeight(), m_tgBitmap11.getHeight());
					m_tgGrid03.setNearAnchor(m_tgTabPage02, Tools.LEFT_TOP, Tools.LEFT_TOP,
							(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 70);
					m_tgGrid03.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid03.m_data != null) {
								UIWindows.getInstance().m_bag.showItemMessage(m_equip_list[m_tgIndex02].m_item);
							}
						}
					});

					m_tgTextbox18 = new DWTextbox(null);
					m_tgTextbox18.setNearAnchor(m_tgGrid03, Tools.LEFT_TOP, Tools.RIGHT_TOP, 10, 55);

					m_tgImageBox04 = new DWImageBox(m_tgBitmap12[0]);//黄色箭头
					m_tgImageBox04.setShow(false);
					m_tgImageBox04.setNearAnchor(m_tgTabPage02, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, (m_tgFrame
							.getShowWidth() / 7 * 4 + 60) / 2 - 60, 20);

					m_tgTextbox_MAXLEVEL = new DWTextbox("装备已强化至顶级");
					m_tgTextbox_MAXLEVEL.setShow(false);
					m_tgTextbox_MAXLEVEL
							.setNearAnchor(m_tgGrid03, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 100);

					m_tgTextbox_maxLevel = new DWTextbox(null);
					m_tgTextbox_maxLevel.setNearAnchor(m_tgImageBox04, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, -120,
							10);

					m_tgTextbox09 = new DWTextbox(null);
					m_tgTextbox09.setNearAnchor(m_tgImageBox04, Tools.RIGHT_TOP, Tools.LEFT_TOP, -180, 0);

					m_qh_tgTextbox31[0] = new DWTextbox(null);
					m_qh_tgTextbox31[0].setNearAnchor(m_tgTextbox09, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

					m_tgListbox_qh01 = new DWListbox(135, 120);
					m_tgListbox_qh01.setNearAnchor(m_tgTextbox09, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

					m_tgTextbox10 = new DWTextbox(null);
					m_tgTextbox10.setNearAnchor(m_tgImageBox04, Tools.LEFT_TOP, Tools.RIGHT_TOP, 20, 0);

					m_qh_tgTextbox31[4] = new DWTextbox(null);
					m_qh_tgTextbox31[4].setNearAnchor(m_tgTextbox10, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 30);

					m_tgLabel02 = new DWTextbox("<mark c=FFBB11>装备</mark>");
					m_tgLabel06 = new DWTextbox("<mark c=FFBB11>等级</mark>");
					m_tgBackground06 = new DWBackground(0, 0, m_tgBackground01[2].getShowWidth(),
							m_tgLabel02.getShowHeight() + 10);
					m_tgBackground06.setNearAnchor(m_tgTabPage02, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 0, 60);
					m_tgTabPage02.addControls(m_tgBackground06);

					m_tgLabel02.setNearAnchor(m_tgBackground06, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 40, 0);
					m_tgLabel06.setNearAnchor(m_tgBackground06, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, -40, 0);
					m_tgTabPage02.addControls(m_tgLabel02);
					m_tgTabPage02.addControls(m_tgLabel06);

					m_tgListbox_QiangHua = new DWListbox(m_tgBackground01[2].getShowWidth() - 20,
							m_tgFrame.getShowHeight() - 190);
					m_tgListbox_QiangHua.setNearAnchor(m_tgTabPage02, Tools.RIGHT_TOP, Tools.RIGHT_TOP, -15, 65);
					m_tgListbox_QiangHua.setLineSpacing(5);

					m_tgTabPage02.addControls(m_tgTextbox06);
					m_tgTabPage02.addControls(m_tgTextbox07);
					m_tgTabPage02.addControls(m_tgTextbox08);
					m_tgTabPage02.addControls(m_tgTextbox09);
					m_tgTabPage02.addControls(m_tgTextbox10);
					m_tgTabPage02.addControls(m_tgTextbox15);
					m_tgTabPage02.addControls(m_qh_tgTextbox31[0]);
					m_tgTabPage02.addControls(m_qh_tgTextbox31[4]);
					m_tgTabPage02.addControls(m_tgTextbox18);
					m_tgTabPage02.addControls(m_tgButton02);
					m_tgTabPage02.addControls(m_tgButton03);
					m_tgTabPage02.addControls(m_tgGrid03);
					m_tgTabPage02.addControls(m_tgImageBox04);
					m_tgTabPage02.addControls(m_tgTextbox_MAXLEVEL);
					m_tgTabPage02.addControls(m_tgTextbox_maxLevel);
					m_tgTabPage02.addControls(m_tgBackground06);
					m_tgTabPage02.addControls(m_tgLabel02);
					m_tgTabPage02.addControls(m_tgLabel06);
					m_tgTabPage02.addControls(m_tgListbox_QiangHua);
					break;
				case 2:
					tiangong_open_state = 2;
					m_tgTabPage03 = new DWTabPage();
					m_tgTabPage03.setName(m_tgString[2]);
					m_tgTabControl01.addTabPage(m_tgTabPage03);

					m_tgLabel03 = new DWTextbox("<mark c=FFBB11>装备</mark>");
					m_tgLabel07 = new DWTextbox("<mark c=FFBB11>灵石</mark>");
					m_tgBackground07 = new DWBackground(0, 0, m_tgBackground01[2].getShowWidth(),
							m_tgLabel03.getShowHeight() + 10);
					m_tgBackground07.setNearAnchor(m_tgTabPage03, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 0, 60);
					m_tgTabPage03.addControls(m_tgBackground07);

					m_tgLabel03.setNearAnchor(m_tgBackground07, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 40, 0);
					m_tgLabel07.setNearAnchor(m_tgBackground07, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, -40, 0);
					m_tgTabPage03.addControls(m_tgLabel03);
					m_tgTabPage03.addControls(m_tgLabel07);

					m_tgTextbox11 = new DWTextbox("<mark c=00ffff>从右侧选择装备进行镶嵌</mark>");
					m_tgTextbox11.setNearAnchor(m_tgTabPage03, Tools.LEFT_TOP, Tools.LEFT_TOP, 40, 20);

					m_tgTextbox12 = new DWTextbox("<mark c=FFBB11>灵石槽可以镶嵌同颜色的灵石</mark>");
					m_tgTextbox12.setNearAnchor(m_tgTabPage03, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);

					m_tgListbox_XiangQian = new DWListbox(m_tgBackground01[2].getShowWidth() - 20,
							m_tgFrame.getShowHeight() - 190);
					m_tgListbox_XiangQian.setNearAnchor(m_tgTabPage03, Tools.RIGHT_TOP, Tools.RIGHT_TOP, -15, 65);
					m_tgListbox_XiangQian.setLineSpacing(5);

					m_tgButton06 = new DWButton("购买灵石", m_tgBitmap04);
					m_tgButton06.setDownImage(m_tgBitmap04_ax);
					m_tgButton06.setNearAnchor(m_tgTabPage03, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM,
							-(m_tgBackground01[2].getShowWidth() + 40), -60);
					m_tgButton06.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							DWGameManager.getInstance().getSendMessage().sendOpenVipShop((byte) 1, (byte) 0);
							DWControlsManager.getInstance().removeControl(m_tgFrame);
						}
					});

					m_tgGrid04 = new DWGrid(m_tgBitmap11);
					m_tgGrid04.setNearAnchor(m_tgTabPage03, Tools.LEFT_TOP, Tools.LEFT_TOP,
							(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 90,
							(m_tgFrame.getShowHeight() - 80) / 2 - 60);
//				
					m_tgGrid04.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid04.m_data != null) {
								UIWindows.getInstance().m_bag.showItemMessage(m_equip_list[m_tgIndex03].m_item);
							}
						}
					});

					m_tgTextbox19 = new DWTextbox(null);
					m_tgTextbox19.setNearAnchor(m_tgGrid04, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 35);

					for (int j = 0; j < 4; j++) {
						m_tgGrid05[j] = new DWGrid(m_tgBitmap11);
						m_tgImageBox_DH_XQ[j] = new DWImageBox(m_tgBitmap_DH[0]);
						m_tgImageBox_DH_XQ[j].setShow(false);
						m_tgImageBox_DH_XQ[j].setTouch(false);
						final int index = j;

						m_tgGrid05[j].addListener(new DWListener() {

							public void OnDoubleClick()
							{

							}

							public void OnClick()
							{
								m_lsIndex02 = index;
								if (m_tgGrid04.m_data != null) {
									popmenu_XiangQian();
								}
								else {
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"请先选择一件装备");
								}
							}
						});
					}

					for (int j = 0; j < 4; j++) {
						m_tgTextbox_BSMS[j] = new DWTextbox(null);
						switch (DWGameManager.AdpaterType) {
							case DWGameManager.AD_HIGH:
								m_tgTextbox_BSMS[j].setFont(DWFont.getFont(25));
								break;
							default:
								m_tgTextbox_BSMS[j].setFont(DWFont.getFont(15));
								break;
						}
					}
					for (int j = 0; j < 4; j++) {
						m_tgTextbox_BSMS[j].setNearAnchor(m_tgGrid05[j], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 5,
								-20);
					}

					m_tgGrid05[0].setNearAnchor(m_tgGrid04, Tools.RIGHT_BOTTOM, Tools.LEFT_TOP, -70, 10);
					m_tgGrid05[1].setNearAnchor(m_tgGrid04, Tools.LEFT_BOTTOM, Tools.RIGHT_TOP, 70, 10);
					m_tgGrid05[2].setNearAnchor(m_tgGrid04, Tools.RIGHT_TOP, Tools.LEFT_BOTTOM, -70, -10);
					m_tgGrid05[3].setNearAnchor(m_tgGrid04, Tools.LEFT_TOP, Tools.RIGHT_BOTTOM, 70, -10);

					for (int j = 0; j < 4; j++) {
						m_tgImageBox_DH_XQ[j]
								.setNearAnchor(m_tgGrid05[j], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
					}

					for (int j = 0; j < m_tgImageBox08.length; j++) {
						if (m_tgImageBox08 == null) {
							Tools.debugPrintln("m_tgBitmap23[" + j + "]=NULL");
						}
						m_tgImageBox08[j] = new DWImageBox(m_tgBitmap23[j]);
						m_tgImageBox08[j].setTouch(false);
					}
					m_tgImageBox08[0].setNearAnchor(m_tgGrid05[0], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
					m_tgImageBox08[1].setNearAnchor(m_tgGrid05[1], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
					m_tgImageBox08[2].setNearAnchor(m_tgGrid05[2], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
					m_tgImageBox08[3].setNearAnchor(m_tgGrid05[3], Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

					m_tgTabPage03.addControls(m_tgTextbox11);
					m_tgTabPage03.addControls(m_tgTextbox12);
					m_tgTabPage03.addControls(m_tgTextbox19);
					m_tgTabPage03.addControls(m_tgButton06);
					m_tgTabPage03.addControls(m_tgListbox_XiangQian);
					m_tgTabPage03.addControls(m_tgGrid04);
					for (int j = 0; j < 4; j++) {
						m_tgTabPage03.addControls(m_tgGrid05[j]);
						m_tgTabPage03.addControls(m_tgImageBox08[j]);
						m_tgTabPage03.addControls(m_tgTextbox_BSMS[j]);
						m_tgTabPage03.addControls(m_tgImageBox_DH_XQ[j]);
					}
					m_tgTabPage03.addControls(m_tgBackground07);
					m_tgTabPage03.addControls(m_tgLabel03);
					m_tgTabPage03.addControls(m_tgLabel07);
					break;
				case 3:
					tiangong_open_state = 3;
					m_tgTabPage04 = new DWTabPage();
					m_tgTabPage04.setName(m_tgString[3]);
					m_tgTabControl01.addTabPage(m_tgTabPage04);

					m_tgLabel04 = new DWTextbox("<mark c=FFBB11>灵石</mark>");
					m_tgLabel08 = new DWTextbox("<mark c=FFBB11>数量</mark>");
					m_tgBackground08 = new DWBackground(0, 0, m_tgBackground01[2].getShowWidth(),
							m_tgLabel04.getShowHeight() + 10);
					m_tgBackground08.setNearAnchor(m_tgTabPage04, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 0, 60);
					m_tgTabPage04.addControls(m_tgBackground08);
					m_tgLabel04.setNearAnchor(m_tgBackground08, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 40, 0);
					m_tgLabel08.setNearAnchor(m_tgBackground08, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, -40, 0);
					m_tgTabPage04.addControls(m_tgLabel04);
					m_tgTabPage04.addControls(m_tgLabel08);

					m_tgTextbox13 = new DWTextbox("<mark c=00ffff>从右侧选择灵石进行合成</mark>");
					m_tgTextbox13.setNearAnchor(m_tgTabPage04, Tools.LEFT_TOP, Tools.LEFT_TOP, 40, 20);

					m_tgListbox_HeCheng = new DWListbox(m_tgBackground01[2].getShowWidth() - 20,
							m_tgFrame.getShowHeight() - 190);
					m_tgListbox_HeCheng.setNearAnchor(m_tgTabPage04, Tools.RIGHT_TOP, Tools.RIGHT_TOP, -15, 65);
					m_tgListbox_HeCheng.setLineSpacing(5);

					m_tgButton07 = new DWButton("合成灵石", m_tgBitmap04);
					m_tgButton07.setDownImage(m_tgBitmap04_ax);
					m_tgButton07.setNearAnchor(m_tgTabPage04, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 20, -60);
					m_tgButton07.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid10[0].m_data != null) {
								Cell cell = m_gem_list[m_tgIndex04];
								ItemGem item = (ItemGem) cell.m_item;
								int num = getGemNum(item.m_key);
								if (num >= 3) {
									DWGameManager.getInstance().getSendMessage().sendSeeNextLevelGem(
											item.m_key);
								}
								else {
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"灵石数量不足");
								}
							}
							else {
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "请先选择灵石");
							}
						}
					});

					m_tgButton08 = new DWButton("购买灵石", m_tgBitmap04);
					m_tgButton08.setDownImage(m_tgBitmap04_ax);
					m_tgButton08.setShow(false);
					m_tgButton08.setTouch(false);
					m_tgButton08.setNearAnchor(m_tgTabPage04, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM,
							-(m_tgBackground01[2].getShowWidth() + 40), -60);

					m_tgGrid09 = new DWGrid(m_tgBitmap11);
					m_tgGrid09.setNearAnchor(m_tgTabPage04, Tools.LEFT_TOP, Tools.LEFT_TOP,
							(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 100,
							(m_tgFrame.getShowHeight() - 80) / 2 - 10);

					m_tgImageBox_DH_HC = new DWImageBox(m_tgBitmap_DH[0]);
					m_tgImageBox_DH_HC.setShow(false);
					m_tgImageBox_DH_HC.setTouch(false);
					m_tgImageBox_DH_HC.setNearAnchor(m_tgGrid09, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);

					m_tgImageBox05 = new DWImageBox(m_tgBitmap12[2]);
					m_tgImageBox05.setNearAnchor(m_tgGrid09, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, 0, 35);

					m_tgImageBox06 = new DWImageBox(m_tgBitmap12[3]);
					m_tgImageBox06.setNearAnchor(m_tgGrid09, Tools.HCENTER_BOTTOM, Tools.HCENTER_TOP, 0, 35);

					m_tgImageBox07 = new DWImageBox(m_tgBitmap12[4]);
					m_tgImageBox07.setNearAnchor(m_tgGrid09, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 0, 35);

					m_tgGrid10[0] = new DWGrid(m_tgBitmap11);
					m_tgGrid10[0].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid10[0].m_data != null) {
								UIWindows.getInstance().m_bag.showItemMessage(m_gem_list[m_tgIndex04].m_item);
							}
						}
					});
					m_tgGrid10[1] = new DWGrid(m_tgBitmap11);
					m_tgGrid10[1].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid10[1].m_data != null) {
								UIWindows.getInstance().m_bag.showItemMessage(m_gem_list[m_tgIndex04].m_item);
							}
						}
					});
					m_tgGrid10[2] = new DWGrid(m_tgBitmap11);
					m_tgGrid10[2].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (m_tgGrid10[2].m_data != null) {
								UIWindows.getInstance().m_bag.showItemMessage(m_gem_list[m_tgIndex04].m_item);
							}
						}
					});
					m_tgGrid10[0].setNearAnchor(m_tgImageBox06, Tools.HCENTER_BOTTOM, Tools.HCENTER_TOP);
					m_tgGrid10[1].setNearAnchor(m_tgImageBox05, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER, 0, 35);
					m_tgGrid10[2].setNearAnchor(m_tgImageBox07, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 0, 35);

					m_tgTextbox14 = new DWTextbox("<mark c=FFBB11>可以将低等级的灵石合成高等级</mark>");
					m_tgTextbox14.setNearAnchor(m_tgTabPage04, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);

					m_tgTextbox20 = new DWTextbox(null);//灵石属性显示
					m_tgTextbox20.setNearAnchor(m_tgGrid10[0], Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 10);

					m_tgTabPage04.addControls(m_tgButton07);
					m_tgTabPage04.addControls(m_tgButton08);
					m_tgTabPage04.addControls(m_tgTextbox13);
					m_tgTabPage04.addControls(m_tgTextbox14);
					m_tgTabPage04.addControls(m_tgTextbox20);
					m_tgTabPage04.addControls(m_tgImageBox05);
					m_tgTabPage04.addControls(m_tgImageBox06);
					m_tgTabPage04.addControls(m_tgImageBox07);
					m_tgTabPage04.addControls(m_tgListbox_HeCheng);
					m_tgTabPage04.addControls(m_tgGrid09);
					m_tgTabPage04.addControls(m_tgImageBox_DH_HC);
					m_tgTabPage04.addControls(m_tgGrid10[0]);
					m_tgTabPage04.addControls(m_tgGrid10[1]);
					m_tgTabPage04.addControls(m_tgGrid10[2]);
					m_tgTabPage04.addControls(m_tgBackground08);
					m_tgTabPage04.addControls(m_tgLabel04);
					m_tgTabPage04.addControls(m_tgLabel08);
					break;
				case 4://TODO
					tiangong_open_state = 4;
					if (DWGameManager.getInstance().m_role.m_lv >= m_dzOpenLevel)
					{
						m_tgTabPage05 = new DWTabPage();
						m_tgTabPage05.setName(m_tgString[4]);
						m_tgTabControl01.addTabPage(m_tgTabPage05);

						m_dzTextbox01 = new DWTextbox("<mark c=FFBB11>装备</mark>");
						m_dzTextbox02 = new DWTextbox("<mark c=FFBB11>等级</mark>");
						m_dzTextbox02.setShow(false);
						m_dzBackground01 = new DWBackground(0, 0, m_tgBackground01[2].getShowWidth(),
								m_dzTextbox01.getShowHeight() + 10);
						m_dzBackground01.setNearAnchor(m_tgTabPage04, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 0, 60);
						m_tgTabPage05.addControls(m_dzBackground01);
						m_dzTextbox01.setNearAnchor(m_dzBackground01, Tools.LEFT_VCENTER, Tools.LEFT_VCENTER, 40, 0);
						m_dzTextbox02.setNearAnchor(m_dzBackground01, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, -40, 0);
						m_tgTabPage05.addControls(m_dzTextbox01);
						m_tgTabPage05.addControls(m_dzTextbox02);

						m_dzTextbox_TiShi = new DWTextbox("<mark c=00ffff>从右侧选择装备进行锻造</mark>");
						m_dzTextbox_TiShi.setNearAnchor(m_tgTabPage05, Tools.LEFT_TOP, Tools.LEFT_TOP, 40, 20);

						m_dzGrid_Copy = new DWGrid(m_tgBitmap11);
						m_dzGrid_Copy.setShow(false);
						m_dzGrid_Copy.setNearAnchor(m_tgTabPage05, Tools.LEFT_TOP, Tools.LEFT_TOP,
								(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, 60);

						m_dzGrid_ZhuangBei = new DWGrid(m_tgBitmap11);
						m_dzGrid_ZhuangBei.setNearAnchor(m_dzGrid_Copy, Tools.LEFT_TOP, Tools.LEFT_TOP);
						m_dzGrid_ZhuangBei.addListener(new DWListener() {

							public void OnDoubleClick()
							{

							}

							public void OnClick()
							{
								if (m_dzGrid_ZhuangBei.m_data != null) {
									UIWindows.getInstance().m_bag
											.showItemMessage(m_equip_list[m_dzIndex_DuanZao].m_item);
								}
							}
						});

						m_dzImageBox_JianTou = new DWImageBox(m_tgBitmap12[0]);//黄色箭头
						m_dzImageBox_JianTou.setShow(false);
						m_dzImageBox_JianTou.setNearAnchor(m_tgTabPage05, Tools.LEFT_TOP, Tools.LEFT_TOP,
								(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60,
								60 + m_dzGrid_Copy.getShowHeight() / 4);

						m_animBox_jiantou = new DWAnimationBox(m_jiantou_Actor);
						m_animBox_jiantou.setNearAnchor(m_dzImageBox_JianTou, Tools.HCENTER_VCENTER,
								Tools.HCENTER_VCENTER);
						m_animBox_jiantou.setShowWideHigh(m_animBox_jiantou.getShowHeight(), 0);
						m_animBox_jiantou.setShow(false);
						m_animBox_jiantou.setTouch(false);

						m_dzGrid_CaiLiao01 = new DWGrid(m_tgBitmap11);
						m_dzGrid_CaiLiao01.setNearAnchor(m_dzGrid_Copy, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0,
								m_dzGrid_Copy.getShowHeight());

						m_dzTextbox_num01 = new DWTextbox("--/--");
						m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);

						m_dzGrid_CaiLiao02 = new DWGrid(m_tgBitmap11);
						m_dzGrid_CaiLiao02.setNearAnchor(m_dzGrid_CaiLiao01, Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER,
								-(m_dzGrid_CaiLiao02.getShowWidth()), 0);

						m_dzTextbox_num02 = new DWTextbox("--/--");
						m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);

						m_dzGrid_BaoHu = new DWGrid(m_dzBitmap_Suo);
						m_dzGrid_BaoHu.setNearAnchor(m_dzGrid_CaiLiao01, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER,
								m_dzGrid_BaoHu.getShowWidth(), 0);
						m_dzGrid_BaoHu.setTouch(false);
						m_dzGrid_BaoHu.addListener(new DWListener() {

							public void OnDoubleClick()
							{

							}

							public void OnClick()
							{
								if (((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv < m_Nobaohulevel) {
									final DWMessageBox mb = new DWMessageBox(
											"提示",
											"是否使用保护石？");
									mb.addListener(new DWListener() {

										public void OnDoubleClick()
										{

										}

										public void OnClick()
										{
											if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
												Cell cell01 = DWGameManager.getInstance().m_role
														.getCellByKeyForRoleBagColumn(m_Stonekey);
												if (cell01 != null) {
													m_dzBaoHuFu_index = true;
													m_animBox_daoju.setShow(false);
													m_dzGrid_BaoHu.m_data = cell01.m_item;
												}
												else {
													DWGameManager.getInstance().addSystemInfo(
															DWGameManager.SYSTEM_INFO_TYPE_B,
															"没有保护石");
												}
											}
											else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {

											}
											DWControlsManager.getInstance().removeControl(mb);
										}
									});
									DWControlsManager.getInstance().addControl(mb);
								}
								else {
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"无法使用保护石");
								}
							}
						});

						m_animBox_daoju = new DWAnimationBox(m_daoju_Actor);
						m_animBox_daoju.setNearAnchor(m_dzGrid_BaoHu, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
						m_animBox_daoju.setShowWideHigh(m_animBox_daoju.getShowHeight(), 0);
						m_animBox_daoju.setShow(false);
						m_animBox_daoju.setTouch(false);

						m_dzTextbox_TiShiBHF = new DWTextbox("点击这里可以使用保护石", m_dzGrid_BaoHu.getShowWidth() * 2);
						m_dzTextbox_TiShiBHF.setNearAnchor(m_dzGrid_BaoHu, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM, 0,
								m_dzGrid_BaoHu.getShowWidth() / 2);
						m_dzTextbox_TiShiBHF.setShow(false);

						m_dzGrid_ZhuangBei_next = new DWGrid(m_tgBitmap11);
						m_dzGrid_ZhuangBei_next.setNearAnchor(m_dzImageBox_JianTou, Tools.LEFT_VCENTER,
								Tools.RIGHT_VCENTER, 5, 0);
						m_dzGrid_ZhuangBei_next.setShow(false);
						m_dzGrid_ZhuangBei_next.addListener(new DWListener() {

							public void OnDoubleClick()
							{

							}

							public void OnClick()
							{
								if (m_dzGrid_ZhuangBei.m_data != null) {
									Item item = m_equip_list[m_dzIndex_DuanZao].m_item.Clone();
									if (((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv >= m_Maxstarlevel) {
										((ItemEquipment) item).m_attrLv = (byte) m_Maxstarlevel;
										UIWindows.getInstance().m_bag
												.showItemMessage(m_equip_list[m_dzIndex_DuanZao].m_item);
									}
									else if (((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv < m_Maxstarlevel) {
										((ItemEquipment) item).m_attrLv = (byte) (((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv + 1);
										for (int i = 0; i < ((ItemEquipment) item).m_attrValue.length; i++) {
											if (((ItemEquipment) item).m_attrValue[i] != 0) {
												if ((int) ((((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrValue[i])
												* (Float.parseFloat(duanZaos[((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv].m_Upattr))) < 1) {
													((ItemEquipment) item).m_attrAddValus_forge[i] = 1;
												}
												else {
													((ItemEquipment) item).m_attrAddValus_forge[i] =
															(int) ((((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrValue[i])
															* (Float.parseFloat(duanZaos[((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv].m_Upattr)));
												}
											}
										}
										UIWindows.getInstance().m_bag.showItemMessage(item);
									}
								}
							}
						});

						m_dzButton_DuanZao = new DWButton(null, m_dzBitmap_DuanZao);
						m_dzButton_DuanZao.setDownImage(m_dzBitmap_DuanZao_ax);
						m_dzButton_DuanZao.setNearAnchor(m_dzGrid_Copy, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
						m_dzButton_DuanZao.addListener(new DWListener() {

							public void OnDoubleClick()
							{

							}

							public void OnClick()
							{
								if (((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv < m_Maxstarlevel) {
									m_dzQiangHuaLevel = ((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv + 1;
								}
								else {
									m_dzQiangHuaLevel = ((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv;
								}
								m_animBox_duanzao.setShow(false);
								if (m_dzGrid_ZhuangBei.m_data != null) {
									if (!m_dzBaoHuFu_index) {
										if (((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv == 0) {
											final DWMessageBox mb = new DWMessageBox(
													"提示",
													"确定消耗"
															+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Money
															+ "金钱将"
															+ "<mark c="
															+ UIBag.getNameColor(m_equip_list[m_dzIndex_DuanZao].m_item.m_quality)
															+ ">"
															+ m_equip_list[m_dzIndex_DuanZao].m_item.m_name
															+ "</mark>"
															+ "进行锻造升级到"
															+ m_dzQiangHuaLevel
															+ "级吗？");
											mb.addListener(new DWListener() {

												public void OnDoubleClick()
												{

												}

												public void OnClick()
												{
													if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {//TODO
														m_animBox_star.setShow(true);
														long nowtime = System.currentTimeMillis();
														doTime(nowtime + 1 * 1000, (byte) 0);
													}
													else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {

													}
													DWControlsManager.getInstance().removeControl(mb);
												}
											});
											DWControlsManager.getInstance().addControl(mb);
										}
										else {
											final DWMessageBox mb = new DWMessageBox(
													"提示",
													"确定消耗"
															+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Money
															+ "金钱将"
															+ "<mark c="
															+ UIBag.getNameColor(m_equip_list[m_dzIndex_DuanZao].m_item.m_quality)
															+ ">"
															+ m_equip_list[m_dzIndex_DuanZao].m_item.m_name
															+ "</mark>"
															+ "进行锻造升级到"
															+ m_dzQiangHuaLevel
															+ "级吗？失败的话，装备将会下降到"
															+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Downlevel
															+ "级");
											mb.addListener(new DWListener() {

												public void OnDoubleClick()
												{

												}

												public void OnClick()
												{
													if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
														m_animBox_star.setShow(true);
														long nowtime = System.currentTimeMillis();
														doTime(nowtime + 1 * 1000, (byte) 0);
													}
													else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {

													}
													DWControlsManager.getInstance().removeControl(mb);
												}
											});
											DWControlsManager.getInstance().addControl(mb);
										}
									}
									else {
										final DWMessageBox mb = new DWMessageBox(
												"提示",
												"确定消耗"
														+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Money
														+ "金钱将"
														+ "<mark c="
														+ UIBag.getNameColor(m_equip_list[m_dzIndex_DuanZao].m_item.m_quality)
														+ ">"
														+ m_equip_list[m_dzIndex_DuanZao].m_item.m_name
														+ "</mark>"
														+ "进行锻造升级到"
														+ m_dzQiangHuaLevel
														+ "级吗？由于使用了保护符，锻造失败将只会损失锻造材料");
										mb.addListener(new DWListener() {

											public void OnDoubleClick()
											{

											}

											public void OnClick()
											{
												if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
													m_animBox_star.setShow(true);
													long nowtime = System.currentTimeMillis();
													doTime(nowtime + 1 * 1000, (byte) 1);
												}
												else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {

												}
												DWControlsManager.getInstance().removeControl(mb);
											}
										});
										DWControlsManager.getInstance().addControl(mb);
									}
								}
								else {
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"请先选择装备");
								}
							}
						});

						m_animBox_duanzao = new DWAnimationBox(m_duanzao_Actor);
						m_animBox_duanzao.setNearAnchor(m_dzButton_DuanZao, Tools.HCENTER_VCENTER,
								Tools.HCENTER_VCENTER);
						m_animBox_duanzao.setShowWideHigh(m_animBox_duanzao.getShowWidth(), 0);
						m_animBox_duanzao.setShow(false);
						m_animBox_duanzao.setTouch(false);

						m_animBox_star = new DWAnimationBox(m_star_Actor);
						m_animBox_star.setNearAnchor(m_dzButton_DuanZao, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
						m_animBox_star.setShowWideHigh(m_animBox_star.getShowWidth(), 0);
						m_animBox_star.setShow(false);
						m_animBox_star.setTouch(false);

						m_tgListbox_DuanZao = new DWListbox(m_tgBackground01[2].getShowWidth() - 20,
								m_tgFrame.getShowHeight() - 190);
						m_tgListbox_DuanZao.setNearAnchor(m_tgTabPage05, Tools.RIGHT_TOP, Tools.RIGHT_TOP, -15, 65);
						m_tgListbox_DuanZao.setLineSpacing(5);

						m_tgTabPage05.addControls(m_dzGrid_Copy);
						m_tgTabPage05.addControls(m_dzTextbox_TiShi);
						m_tgTabPage05.addControls(m_dzImageBox_JianTou);
						m_tgTabPage05.addControls(m_animBox_jiantou);
						m_tgTabPage05.addControls(m_dzGrid_ZhuangBei);
						m_tgTabPage05.addControls(m_dzGrid_ZhuangBei_next);
						m_tgTabPage05.addControls(m_dzGrid_CaiLiao01);
						m_tgTabPage05.addControls(m_dzGrid_CaiLiao02);
						m_tgTabPage05.addControls(m_dzTextbox_TiShiBHF);
						m_tgTabPage05.addControls(m_dzTextbox_num01);
						m_tgTabPage05.addControls(m_dzTextbox_num02);
						m_tgTabPage05.addControls(m_dzButton_DuanZao);
						m_tgTabPage05.addControls(m_animBox_duanzao);
						m_tgTabPage05.addControls(m_dzGrid_BaoHu);
						m_tgTabPage05.addControls(m_animBox_daoju);
						m_tgTabPage05.addControls(m_animBox_star);
						m_tgTabPage05.addControls(m_tgListbox_DuanZao);
						m_tgTabPage05.addControls(m_dzBackground01);
						m_tgTabPage05.addControls(m_dzTextbox01);
						m_tgTabPage05.addControls(m_dzTextbox02);
					}
					else {
						m_tgTabPage05 = new DWTabPage();
						m_tgTabPage05.setName(m_tgString[4]);
						m_tgTabControl01.addTabPage(m_tgTabPage05);

						m_dzTextbox_level = new DWTextbox(m_dzOpenLevel + "级开启装备锻造");
						m_dzTextbox_level.setNearAnchor(m_tgTabPage05, Tools.LEFT_TOP, Tools.LEFT_TOP,
								(m_tgFrame.getShowWidth() / 7 * 4 + 60) / 2 - 60, m_tgFrame.getShowHeight() / 3);

						m_tgTabPage05.addControls(m_dzTextbox_level);
					}
					break;
			}
		}

		m_tgFrame.addControl(m_tgTitle);
		m_tgFrame.addControl(m_tgImageBox_BT);
		m_tgFrame.addControl(m_tgImageBox01);
		m_tgFrame.addControl(m_tgBackground01[1]);
		m_tgFrame.addControl(m_tgBackground01[2]);
		m_tgFrame.addControl(m_tgTabControl01);
		DWControlsManager.getInstance().addControl(m_tgFrame);
	}

	/**
	 * 锻造计时
	 */
	public void doTime(final long time, final byte tpye)
	{
		new Thread(new Runnable() {

			public void run()
			{
				while (true) {
					long nowtime = System.currentTimeMillis();
					if (nowtime >= time) {
						DWGameManager.getInstance().getSendMessage().sendEquipmentForge(
								m_equip_list[m_dzIndex_DuanZao].m_item.m_guid, tpye);
						m_animBox_star.setShow(false);
						break;
					}
					else {
						Thread.yield();
					}
				}
			}
		}).start();
	}

	/**
	 * 装备熔炼列表
	 */
	boolean m_flag_ronglian = true;
	int m_size;
	DWCheckbox[] m_tgCheckbox01;

	public void listbox_RongLian()
	{
		if (m_tgListbox_RongLianCao != null) {
			if (!m_flag_ronglian)
			{
				for (int i = 0; i < m_size; i++)
				{
					if (m_tgCheckbox01[i].getChecked())
					{
						m_tgListbox_RongLianCao.removeSubItem(i);
					}
				}
				m_tgListbox_RongLianCao.refreshControl();
				return;
			}
			m_tgListbox_RongLianCao.removeAllSubItem();
			if (m_equip_list != null) {
				DWListSubItem[] m_tgLSItem01 = new DWListSubItem[m_equip_list.length];
				DWTextbox[] m_tgTextbox01 = new DWTextbox[m_equip_list.length];
				DWTextbox[] m_tgTextbox04 = new DWTextbox[m_equip_list.length];
				m_tgCheckbox01 = new DWCheckbox[m_equip_list.length];
				m_size = m_equip_list.length;
				for (int j = 0; j < m_equip_list.length; j++) {
					m_tgLSItem01[j] = new DWListSubItem();
					m_tgLSItem01[j].setAutoWideHigh(false);
					m_tgLSItem01[j].setShowWideHighUn(m_tgListbox_RongLianCao.getShowWidth(), 40);
					m_tgCheckbox01[j] = new DWCheckbox();
					m_tgCheckbox01[j].setNearAnchor(m_tgLSItem01[j],
							Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_tgCheckbox01[j].setChecked(m_equip_list[j].m_selected);
					m_tgCheckbox01[j].addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							final int index = m_tgListbox_RongLianCao.getTouchIndex();
							Tools.debugPrintln("OnClick index=" + index);
							boolean flag = m_tgCheckbox01[index].getChecked();

							if (flag && ((ItemEquipment) m_equip_list[index].m_item).m_equipGemsSize == 0) {
								if (((ItemEquipment) m_equip_list[index].m_item).m_strengthenLevel > 0) {
									final DWMessageBox mb = new DWMessageBox("提示",
											"熔炼将<mark c=FF0000>失去装备上已有的精魂</mark>，您确定？");
									mb.addListener(new DWListener() {

										public void OnDoubleClick()
										{

										}

										public void OnClick()
										{
											if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
												DWControlsManager.getInstance().removeControl(mb);

												m_equip_list[index].m_selected = m_tgCheckbox01[index]
														.getChecked();
												addCache(m_equip_list[index]);
											}
											else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
												DWControlsManager.getInstance().removeControl(mb);
												m_tgCheckbox01[index].setChecked(false);
											}
										}
									});
									DWControlsManager.getInstance().addControl(mb);
									return;
								}
							}
							else if (flag && ((ItemEquipment) m_equip_list[index].m_item).m_equipGemsSize > 0) {
								if (((ItemEquipment) m_equip_list[index].m_item).m_strengthenLevel > 0) {
									if (((ItemEquipment) m_equip_list[index].m_item).m_hasGem[0] == ItemConstants.含有宝石_是
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[1] == ItemConstants.含有宝石_是
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[2] == ItemConstants.含有宝石_是
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[3] == ItemConstants.含有宝石_是) {
										final DWMessageBox mb = new DWMessageBox("提示",
												"熔炼将<mark c=FF0000>失去装备上已有的精魂和灵石</mark>，您确定？");
										mb.addListener(new DWListener() {

											public void OnDoubleClick()
											{

											}

											public void OnClick()
											{
												if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
													DWControlsManager.getInstance().removeControl(mb);

													m_equip_list[index].m_selected = m_tgCheckbox01[index]
															.getChecked();
													addCache(m_equip_list[index]);
												}
												else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
													DWControlsManager.getInstance().removeControl(mb);
													m_tgCheckbox01[index].setChecked(false);
												}
											}
										});
										DWControlsManager.getInstance().addControl(mb);
										return;
									}
									else if (((ItemEquipment) m_equip_list[index].m_item).m_hasGem[0] == ItemConstants.含有宝石_否
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[1] == ItemConstants.含有宝石_否
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[2] == ItemConstants.含有宝石_否
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[3] == ItemConstants.含有宝石_否) {
										final DWMessageBox mb = new DWMessageBox("提示",
												"熔炼将<mark c=FF0000>失去装备上已有的精魂</mark>，您确定？");
										mb.addListener(new DWListener() {

											public void OnDoubleClick()
											{

											}

											public void OnClick()
											{
												if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
													DWControlsManager.getInstance().removeControl(mb);

													m_equip_list[index].m_selected = m_tgCheckbox01[index]
															.getChecked();
													addCache(m_equip_list[index]);
												}
												else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
													DWControlsManager.getInstance().removeControl(mb);
													m_tgCheckbox01[index].setChecked(false);
												}
											}
										});
										DWControlsManager.getInstance().addControl(mb);
										return;
									}
								}
								else if (((ItemEquipment) m_equip_list[index].m_item).m_strengthenLevel == 0) {
									if (((ItemEquipment) m_equip_list[index].m_item).m_hasGem[0] == ItemConstants.含有宝石_是
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[1] == ItemConstants.含有宝石_是
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[2] == ItemConstants.含有宝石_是
											|| ((ItemEquipment) m_equip_list[index].m_item).m_hasGem[3] == ItemConstants.含有宝石_是) {
										final DWMessageBox mb = new DWMessageBox("提示",
												"熔炼将<mark c=FF0000>失去装备上已有的灵石</mark>，您确定？");
										mb.addListener(new DWListener() {

											public void OnDoubleClick()
											{

											}

											public void OnClick()
											{
												if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
													DWControlsManager.getInstance().removeControl(mb);

													m_equip_list[index].m_selected = m_tgCheckbox01[index]
															.getChecked();
													addCache(m_equip_list[index]);
												}
												else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
													DWControlsManager.getInstance().removeControl(mb);
													m_tgCheckbox01[index].setChecked(false);
												}
											}
										});
										DWControlsManager.getInstance().addControl(mb);
										return;
									}
								}
							}
							m_equip_list[index].m_selected = m_tgCheckbox01[index].getChecked();
							addCache(m_equip_list[index]);
						}
					});
					m_tgTextbox01[j] = new DWTextbox("<mark c=" + UIBag.getNameColor(m_equip_list[j].m_item.m_quality)
							+ ">" + m_equip_list[j].m_item.m_name + "</mark>");
					m_tgTextbox01[j]
							.setNearAnchor(m_tgCheckbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 60, 0);

					m_tgTextbox04[j] = new DWTextbox("<mark c=FFBB11>" + ((ItemEquipment) m_equip_list[j].m_item)
							.getProductOrder((short) ((ItemEquipment) m_equip_list[j].m_item).m_strengthenLevel)
							+ "</mark>");
					switch (DWGameManager.AdpaterType) {
						case DWGameManager.AD_HIGH:
							m_tgTextbox04[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 270, 0);
							break;
						default:
							m_tgTextbox04[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 110, 0);
							break;
					}

					m_tgLSItem01[j].addControls(m_tgCheckbox01[j]);
					m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
					m_tgLSItem01[j].addControls(m_tgTextbox04[j]);
					m_tgListbox_RongLianCao.addSubItem(m_tgLSItem01[j]);
				}
			}
		}
	}

	/**
	 * 装备强化列表
	 */
	public void listbox_QiangHua()
	{
		if (m_equip_list != null) {
			final DWListSubItem[] m_tgLSItem01 = new DWListSubItem[m_equip_list.length];
			DWTextbox[] m_tgTextbox01 = new DWTextbox[m_equip_list.length];
			DWTextbox[] m_tgTextbox02 = new DWTextbox[m_equip_list.length];
			DWImageBox[] m_tgImageBox01 = new DWImageBox[m_equip_list.length];

			for (int j = 0; j < m_equip_list.length; j++) {
				m_tgLSItem01[j] = new DWListSubItem();
				m_tgLSItem01[j].setAutoWideHigh(false);
				m_tgLSItem01[j].setShowWideHighUn(m_tgListbox_QiangHua.getShowWidth(), 30);

				m_tgTextbox01[j] = new DWTextbox("<mark c=" + UIBag.getNameColor(m_equip_list[j].m_item.m_quality)
						+ ">" + m_equip_list[j].m_item.m_name + "</mark>");
				m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 30, 0);

				m_tgTextbox02[j] = new DWTextbox("<mark c=FFBB11>"
						+ ((ItemEquipment) m_equip_list[j].m_item)
								.getProductOrder((short) ((ItemEquipment) m_equip_list[j].m_item).m_strengthenLevel)
						+ "</mark>");

				switch (DWGameManager.AdpaterType) {
					case DWGameManager.AD_HIGH:
						m_tgTextbox02[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 300, 0);
						break;
					default:
						m_tgTextbox02[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 140, 0);
						break;
				}

				if (Cell.TYPE_COLUMN_EQUIP == m_equip_list[j].m_column_type) {
					m_tgImageBox01[j] = new DWImageBox(m_Bitmap_ZB);
					m_tgImageBox01[j].setNearAnchor(m_tgTextbox01[j], Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER);
				}

				m_tgListbox_QiangHua.addListener(new DWListener() {

					public void OnDoubleClick()
					{

					}

					public void OnClick()
					{
						int index = m_tgListbox_QiangHua.getTouchIndex();
						m_tgIndex02 = index;
						Cell cell = m_equip_list[m_tgIndex02];
						ItemEquipment equip = (ItemEquipment) cell.m_item;

						m_qh_tgTextbox31[0].setText(null);
						m_qh_tgTextbox31[4].setText(null);

						if (equip.m_strengthenLevel >= equip.m_maxStrengthenLevel) {
							refreshListbox_QiangHua();
							m_tgTextbox18.setText("<mark c=" + UIBag.getNameColor(equip.m_quality)
									+ ">" + equip.m_name + "</mark>");
							m_tgGrid03.setImage(m_tgBitmap11);
							m_tgGrid03.m_data = cell;
							m_tgTextbox_MAXLEVEL.setShow(true);
						}
						else {
							DWGameManager.getInstance().getSendMessage().sendStrengthenNextLevelValues(
									(byte) m_equip_list[m_tgIndex02].m_column_type, m_equip_list[m_tgIndex02].m_index);
							m_tgTextbox18.setText("<mark c=" + UIBag.getNameColor(equip.m_quality)
									+ ">" + equip.m_name + "</mark>");
							PatternChange(0);//装备强化属性改变值
							m_tgGrid03.setImage(m_tgBitmap11);
							m_tgImageBox04.setShow(true);
							m_tgTextbox_MAXLEVEL.setShow(false);
							m_tgGrid03.m_data = cell;
						}
					}
				});
				m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
				m_tgLSItem01[j].addControls(m_tgTextbox02[j]);
				m_tgLSItem01[j].addControls(m_tgImageBox01[j]);
				m_tgListbox_QiangHua.addSubItem(m_tgLSItem01[j]);
			}
		}
	}

	/**
	 * 灵石镶嵌列表
	 */
	public void listbox_XiangQian()
	{
		if (m_equip_list != null) {

			if (m_tgListbox_XiangQian != null) {
				m_tgListbox_XiangQian.removeAllSubItem();
			}

			for (int j = 0; j < m_equip_list.length; j++) {
				DWListSubItem[] m_tgLSItem01 = new DWListSubItem[m_equip_list.length];
				DWTextbox[] m_tgTextbox01 = new DWTextbox[m_equip_list.length];
				DWImageBox[][] m_tgImageBox01 = new DWImageBox[m_equip_list.length][4];
				DWImageBox[] m_tgImageBox02 = new DWImageBox[m_equip_list.length];
				if (m_equip_list[j] != null && m_equip_list[j] instanceof Cell) {
					Cell cell = (Cell) m_equip_list[j];
					if (cell.m_item != null && cell.m_item instanceof ItemEquipment) {
						ItemEquipment equip = (ItemEquipment) cell.m_item;
						m_tgLSItem01[j] = new DWListSubItem();
						m_tgLSItem01[j].setAutoWideHigh(false);
						m_tgLSItem01[j].setShowWideHighUn(m_tgListbox_XiangQian.getShowWidth(), 30);
						m_tgTextbox01[j] = new DWTextbox("<mark c="
								+ UIBag.getNameColor(m_equip_list[j].m_item.m_quality)
								+ ">"
								+ m_equip_list[j].m_item.m_name
								+ "</mark>");
						for (int i = 0; i < equip.m_equipGemsSize; i++) {
							m_tgImageBox01[j][i] = new DWImageBox(equip.m_gemSamllIcon[i]);
						}
						if (Cell.TYPE_COLUMN_EQUIP == m_equip_list[j].m_column_type) {
							m_tgImageBox02[j] = new DWImageBox(m_Bitmap_ZB);
							m_tgImageBox02[j].setNearAnchor(m_tgTextbox01[j], Tools.RIGHT_VCENTER, Tools.LEFT_VCENTER);
						}

						m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 30, 0);
						if (m_tgImageBox01[j][0] != null
								&& m_tgImageBox01[j][1] != null
								&& m_tgImageBox01[j][2] != null
								&& m_tgImageBox01[j][3] != null) {
							switch (DWGameManager.AdpaterType) {
								case DWGameManager.AD_HIGH:
									m_tgImageBox01[j][0].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_VCENTER,
											Tools.LEFT_VCENTER, 300, 0);
									m_tgImageBox01[j][1].setNearAnchor(m_tgImageBox01[j][0], Tools.LEFT_TOP,
											Tools.RIGHT_TOP);
									m_tgImageBox01[j][2].setNearAnchor(m_tgImageBox01[j][1], Tools.LEFT_TOP,
											Tools.RIGHT_TOP);
									m_tgImageBox01[j][3].setNearAnchor(m_tgImageBox01[j][2], Tools.LEFT_TOP,
											Tools.RIGHT_TOP);

									break;
								default:
									m_tgImageBox01[j][0].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_VCENTER,
											Tools.LEFT_VCENTER, 140, 0);
									m_tgImageBox01[j][1].setNearAnchor(m_tgImageBox01[j][0], Tools.LEFT_TOP,
											Tools.RIGHT_TOP);
									m_tgImageBox01[j][2].setNearAnchor(m_tgImageBox01[j][1], Tools.LEFT_TOP,
											Tools.RIGHT_TOP);
									m_tgImageBox01[j][3].setNearAnchor(m_tgImageBox01[j][2], Tools.LEFT_TOP,
											Tools.RIGHT_TOP);
									break;
							}
						}
					}
				}
				m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
				for (int i = 0; i < 4; i++) {
					m_tgLSItem01[j].addControls(m_tgImageBox01[j][i]);
				}
				m_tgLSItem01[j].addControls(m_tgImageBox02[j]);
				m_tgListbox_XiangQian.addSubItem(m_tgLSItem01[j]);
			}

			m_tgListbox_XiangQian.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					m_lsIndex02 = -1;//宝石槽下标(-1没有点击宝石槽)
					int index = m_tgListbox_XiangQian.getTouchIndex();
					m_tgIndex03 = index;
					m_tgTextbox19.setText("<mark c=" + UIBag.getNameColor(m_equip_list[m_tgIndex03].m_item.m_quality)
							+ ">" + m_equip_list[m_tgIndex03].m_item.m_name + "</mark>");

					m_tgGrid04.m_data = m_equip_list[m_tgIndex03];
					refreshListbox_XiangQianBaoShi();
				}
			});
		}
	}

	/**
	 * 灵石合成列表
	 */
	public void listbox_HeCheng()
	{
		if (m_gem_list != null) {
			DWListSubItem[] m_tgLSItem01 = new DWListSubItem[m_gem_list.length];
			DWTextbox[] m_tgTextbox01 = new DWTextbox[m_gem_list.length];
			DWTextbox[] m_tgTextbox02 = new DWTextbox[m_gem_list.length];
			for (int j = 0; j < m_gem_list.length; j++) {
				m_tgLSItem01[j] = new DWListSubItem();
				m_tgLSItem01[j].setAutoWideHigh(false);
				m_tgLSItem01[j].setShowWideHighUn(m_tgListbox_HeCheng.getShowWidth(), 30);
				m_tgTextbox01[j] = new DWTextbox("<mark c=" + UIBag.getNameColor(m_gem_list[j].m_item.m_quality)
						+ ">" + m_gem_list[j].m_item.m_name + "</mark>");

				m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);

				m_tgTextbox02[j] = new DWTextbox("" + m_gem_list[j].m_item.m_num);

				switch (DWGameManager.AdpaterType) {
					case DWGameManager.AD_HIGH:
						m_tgTextbox02[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 380, 0);
						break;
					default:
						m_tgTextbox02[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 200, 0);
						break;
				}

				m_tgListbox_HeCheng.addListener(new DWListener() {

					public void OnDoubleClick()
					{

					}

					public void OnClick()
					{
						int index = m_tgListbox_HeCheng.getTouchIndex();
						m_tgIndex04 = index;
						ItemGem gem = (ItemGem) m_gem_list[m_tgIndex04].m_item;
						if (gem == null || m_AnimCatch != null) {
							return;
						}
						int num = getGemNum(gem.m_key);
						refreshListbox_HeCheng();
						m_tgButton08.setShow(false);
						m_tgButton08.setTouch(false);
						m_tgTextbox20.setText("<mark c="
								+ UIBag.getNameColor(gem.m_quality)
								+ ">"
								+ gem.m_name + "</mark>"
								+ DWControlTools.CHANGE_ROW
								+ Attribute.ATTRIBUTE_NAME[gem.m_attrindex]
								+ ": +"
								+ gem.m_attrvalue);
						if (num >= 3) {
							for (int i = 0; i < 3; i++) {
								m_tgGrid10[i].m_data = m_gem_list[m_tgIndex04].m_item;
								m_tgButton08.setShow(false);
								m_tgButton08.setTouch(false);
							}
						}
						else if (num == 2) {
							for (int i = 0; i < 2; i++) {
								m_tgGrid10[i].m_data = m_gem_list[m_tgIndex04].m_item;
								m_tgButton08.setShow(true);
								m_tgButton08.setTouch(true);
								m_tgButton08.addListener(new DWListener() {

									public void OnDoubleClick()
									{

									}

									public void OnClick()
									{
										DWGameManager.getInstance().getSendMessage()
												.sendOpenVipShop((byte) 1, (byte) 0);
										DWControlsManager.getInstance().removeControl(m_tgFrame);
									}
								});
							}
						}
						else if (num == 1) {
							m_tgGrid10[0].m_data = m_gem_list[m_tgIndex04].m_item;
							m_tgButton08.setShow(true);
							m_tgButton08.setTouch(true);
							m_tgButton08.addListener(new DWListener() {

								public void OnDoubleClick()
								{

								}

								public void OnClick()
								{
									DWGameManager.getInstance().getSendMessage().sendOpenVipShop((byte) 1, (byte) 0);
									DWControlsManager.getInstance().removeControl(m_tgFrame);
								}
							});
						}
						m_tgGrid09.m_data = null;
					}
				});
				m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
				m_tgLSItem01[j].addControls(m_tgTextbox02[j]);
				m_tgListbox_HeCheng.addSubItem(m_tgLSItem01[j]);
			}
		}
	}

	/**
	 * 装备锻造列表
	 */
	public void listbox_DuanZao()//TODO 装备锻造列表
	{
		if (DWGameManager.getInstance().m_role.m_lv >= m_dzOpenLevel)
		{
			if (m_equip_list != null) {
				final DWListSubItem[] m_tgLSItem01 = new DWListSubItem[m_equip_list.length];
				DWTextbox[] m_tgTextbox01 = new DWTextbox[m_equip_list.length];

				for (int j = 0; j < m_equip_list.length; j++) {
					m_tgLSItem01[j] = new DWListSubItem();
					m_tgLSItem01[j].setAutoWideHigh(false);
					m_tgLSItem01[j].setShowWideHighUn(m_tgListbox_DuanZao.getShowWidth(), 30);

					m_tgTextbox01[j] = new DWTextbox("<mark c=" + UIBag.getNameColor(m_equip_list[j].m_item.m_quality)
							+ ">" + m_equip_list[j].m_item.m_name + "</mark>");
					m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 30, 0);

					m_tgListbox_DuanZao.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							refreshListbox_DuanZao();
							int index = m_tgListbox_DuanZao.getTouchIndex();
							m_dzIndex_DuanZao = index;
							Cell cell = m_equip_list[m_dzIndex_DuanZao];
							m_dzGrid_ZhuangBei.m_data = cell;
							m_dzGrid_ZhuangBei_next.m_data = cell;
							m_dzHengYi_x = true;

							Cell cell01 = null;
							if (duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount > 0) {
								cell01 = DWGameManager.getInstance().m_role
										.getCellByKeyForRoleBagColumn(duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1key);

								if (cell01 != null && cell01.m_item != null) {
									if (cell01.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount) {
										m_dzTextbox_num02
												.setText(getItemNum(cell01.m_item.m_key)
														+ "/"
														+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount);
										m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP,
												Tools.HCENTER_BOTTOM);
									}
									else {
										m_dzTextbox_num02
												.setText("<mark c=FF0000>"
//														+ cell01.m_item.m_num
														+ getItemNum(cell01.m_item.m_key)
														+ "</mark>"
														+ "/"
														+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount);
										m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP,
												Tools.HCENTER_BOTTOM);
									}
								}
								else {
									m_dzTextbox_num02
											.setText("<mark c=FF0000>0</mark>/"
													+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount);
									m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP,
											Tools.HCENTER_BOTTOM);
								}
							}

							Cell cell02 = null;
							if (duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount > 0) {
								cell02 = DWGameManager.getInstance().m_role
										.getCellByKeyForRoleBagColumn(duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2key);

								if (cell02 != null && cell02.m_item != null) {
									if (cell02.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount) {
										m_dzTextbox_num01
												.setText(getItemNum(cell02.m_item.m_key)
														+ "/"
														+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount);
										m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP,
												Tools.HCENTER_BOTTOM);
									}
									else {
										m_dzTextbox_num01
												.setText("<mark c=FF0000>"
//														+ cell02.m_item.m_num
														+ getItemNum(cell02.m_item.m_key)
														+ "</mark>"
														+ "/"
														+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount);
										m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP,
												Tools.HCENTER_BOTTOM);
									}
								}
								else {
									m_dzTextbox_num01
											.setText("<mark c=FF0000>0</mark>/"
													+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount);
									m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP,
											Tools.HCENTER_BOTTOM);
								}
							}

							if (cell01 != null && cell01.m_item != null && cell02 != null && cell02.m_item != null) {
								if (cell01.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount
										&&
										cell02.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount) {
									m_animBox_duanzao.setShow(true);
									if ((((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv) < m_Maxstarlevel
											&& (((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv) > 0) {
										m_dzGrid_BaoHu.setImage(m_tgBitmap11);
										m_dzGrid_BaoHu.setTouch(true);
										m_animBox_daoju.setShow(true);
										m_dzTextbox_TiShiBHF.setShow(true);
									}
								}
							}

							Cell cell_linshi_01 = new Cell();
							Item item1 = new Item();//创建一个临时的item 来放道具图标
							item1.m_iconId = duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1icon;
							item1.m_icon = IconManger
									.getInstance()
									.getIcon(
											(int) duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1icon);
							cell_linshi_01.m_item = item1;

							m_dzGrid_CaiLiao02.m_data = cell_linshi_01.m_item;

							item1 = null;
							cell_linshi_01 = null;

							Cell cell_linshi_02 = new Cell();
							Item item2 = new Item();
							item2.m_iconId = duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2icon;
							item2.m_icon = IconManger
									.getInstance()
									.getIcon(
											(int) duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2icon);
							cell_linshi_02.m_item = item2;

							m_dzGrid_CaiLiao01.m_data = cell_linshi_02.m_item;

							item2 = null;
							cell_linshi_02 = null;
						}
					});
					m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
					m_tgListbox_DuanZao.addSubItem(m_tgLSItem01[j]);
				}
			}
		}
	}

	/**
	 * 返回装备熔炼列表第一项
	 * @return
	 */
	public DWListSubItem ronglian_open()
	{
		if (DWControlsManager.getInstance().contains(m_tgFrame) == false) {
			return null;
		}
		else {
			if (m_tgTabControl01.getPageIndex() != 0) {
				return null;
			}
			return m_tgListbox_RongLianCao.getListSubItem(0);
		}
	}

	/** 切换强化页 */
	public void qiehuan_qianghua()
	{
		m_tgTabControl01.setSelectPage(1);
		refreshEquipList(1);
		if (m_tgListbox_QiangHua != null) {
			m_tgListbox_QiangHua.removeAllSubItem();
			listbox_QiangHua();
		}
		refreshText();
		refreshListbox_RongLian();
		refreshListbox_XiangQian();
		refreshListbox_XiangQianBaoShi();
		refreshListbox_HeCheng();
		refreshListbox_DuanZao();
		delCacheList();
	}

	/** 切换镶嵌页 */
	public void qiehuan_xiangqian()
	{
		m_tgTabControl01.setSelectPage(2);
		refreshEquipList(2);
		if (m_tgListbox_XiangQian != null) {
			m_tgListbox_XiangQian.removeAllSubItem();
			listbox_XiangQian();
		}
		if (m_listbox_LingShiList != null) {
			m_listbox_LingShiList.removeAllSubItem();
			listbox_LingShiList();
		}
		refreshText();
		refreshListbox_RongLian();
		refreshListbox_QiangHua();
		refreshListbox_HeCheng();
		refreshListbox_DuanZao();
		delCacheList();
	}

	/**
	 * 返回装备强化列表第一项
	 * @return
	 */
	public DWListSubItem qianghua_open()
	{
		if (DWControlsManager.getInstance().contains(m_tgFrame) == false) {
			return null;
		}
		else {
			if (m_tgTabControl01.getPageIndex() != 1) {
				return null;
			}
			return m_tgListbox_QiangHua.getListSubItem(0);
		}
	}

	/**
	 * 返回宝石镶嵌列表第一项
	 * @return
	 */
	public DWListSubItem xiangqian_open()
	{
		if (DWControlsManager.getInstance().contains(m_tgFrame) == false) {
			return null;
		}
		else {
			if (m_tgTabControl01.getPageIndex() != 2) {
				return null;
			}
			return m_tgListbox_XiangQian.getListSubItem(0);
		}
	}

	/**
	 * 返回宝石合成列表第一项
	 * @return
	 */
	public DWListSubItem hecheng_open()
	{
		if (DWControlsManager.getInstance().contains(m_tgFrame) == false) {
			return null;
		}
		else {
			if (m_tgTabControl01.getPageIndex() != 3) {
				return null;
			}
			return m_tgListbox_HeCheng.getListSubItem(0);
		}
	}

	/** 刷新装备对应的镶嵌宝石槽 */
	private void refreshListbox_XiangQianBaoShi()
	{
		if (m_tgGrid05 == null
				|| m_tgGrid04.m_data == null
				|| !(m_tgGrid04.m_data instanceof Cell)) {
			return;
		}
		Cell cell = (Cell) m_tgGrid04.m_data;
		if (cell.m_item == null || !(cell.m_item instanceof ItemEquipment)) {
			return;
		}
		ItemEquipment equip = (ItemEquipment) cell.m_item;
		if (equip.m_equipGemsSize != m_tgGrid05.length) {
			for (int i = 0; i < m_tgGrid05.length; i++) {
				m_tgGrid05[i].m_data = null;
			}
		}
		else {
			for (int i = 0; i < m_tgGrid05.length; i++) {
				if (equip.m_hasGem[i] == ItemConstants.含有宝石_是) {
					Item gem = new ItemGem();
					gem.m_icon = equip.m_gemIcon[i];

					m_tgGrid05[i].m_data = gem;
					m_tgTextbox_BSMS[i].setText(equip.m_nameGem[i] + DWControlTools.CHANGE_ROW
							+ equip.getGemDatas(i));
					gem = null;
				}
				else {
					m_tgGrid05[i].m_data = null;
					m_tgTextbox_BSMS[i].setText("<mark c=ABABAB>尚未镶嵌</mark>");
				}
			}
		}
	}

	/**
	 * 刷新装备熔炼界面
	 */
	private void refreshListbox_RongLian()
	{
		if (m_tgGrid_RL01[0] == null) {
			return;
		}
		for (int i = 0; i < m_tgGrid_RL01.length; i++) {
			m_tgGrid_RL01[i].m_data = null;
			m_tgGrid_RL01[i].setImage(null);
		}
	}

	/**
	 * 刷新装备强化界面
	 */
	private void refreshListbox_QiangHua()
	{
		if (m_tgGrid03 == null) {
			return;
		}
		m_tgGrid03.m_data = null;
		m_tgGrid03.setImage(null);
		m_tgImageBox04.setShow(false);
		m_tgTextbox_MAXLEVEL.setShow(false);
		m_tgTextbox18.setText(null);
		m_tgTextbox09.setText(null);
		m_tgTextbox10.setText(null);
		m_tgTextbox_maxLevel.setText(null);
		m_tgTextbox15.setText(null);
		m_qh_tgTextbox31[0].setText(null);
		m_qh_tgTextbox31[4].setText(null);
	}

	/**
	 * 刷新灵石镶嵌界面
	 */
	private void refreshListbox_XiangQian()
	{
		if (m_tgGrid04 == null) {
			return;
		}
		m_tgGrid04.m_data = null;
		for (int i = 0; i < 4; i++) {
			m_tgGrid05[i].m_data = null;
			m_tgTextbox_BSMS[i].setText(null);
		}
		m_tgTextbox19.setText(null);
	}

	/**
	 * 刷新灵石合成界面
	 */
	private void refreshListbox_HeCheng()
	{
		if (m_tgGrid10 != null) {
			for (int i = 0; i < m_tgGrid10.length; i++) {
				m_tgGrid10[i].m_data = null;
			}
		}
		if (m_tgGrid09 != null) {
			m_tgGrid09.m_data = null;
		}
		m_AnimCatch = null;
		m_AnimIndex = -1;
		m_rdtime = -1;
		m_tgImageBox_DH_HC.setShow(false);
		m_tgTextbox20.setText(null);
		m_tgButton08.setShow(false);
		m_tgButton08.setTouch(false);
	}

	/**
	 * 刷新装备锻造界面
	 */
	private void refreshListbox_DuanZao()
	{
		if (DWGameManager.getInstance().m_role.m_lv >= m_dzOpenLevel) {
			if (m_dzGrid_ZhuangBei != null) {
				m_dzGrid_ZhuangBei.m_data = null;
			}
			if (m_dzGrid_ZhuangBei_next != null) {
				m_dzGrid_ZhuangBei_next.setShow(false);
				m_dzGrid_ZhuangBei_next.m_data = null;
			}
			m_dzIndex_DuanZao = 0;
			m_dzImageBox_JianTou.setShow(false);
			m_animBox_jiantou.setShow(false);
			m_animBox_duanzao.setShow(false);
			m_dzTextbox_TiShiBHF.setShow(false);
			m_dzGrid_BaoHu.setImage(m_dzBitmap_Suo);
			m_dzGrid_BaoHu.setTouch(false);
			m_dzTextbox_num01.setText("--/--");
			m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
			m_dzTextbox_num02.setText("--/--");
			m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
			m_dzGrid_CaiLiao01.m_data = null;
			m_dzGrid_CaiLiao02.m_data = null;
			m_dzBaoHuFu_index = false;
			m_dzGrid_BaoHu.m_data = null;
			m_animBox_daoju.setShow(false);
			m_animBox_star.setShow(false);
			m_dzHengYi_x = false;
			m_dzGrid_x = 0;
			m_dzGrid_ZhuangBei.setNearAnchor(m_dzGrid_Copy, Tools.LEFT_TOP, Tools.LEFT_TOP);
		}
	}

	/**
	 * 刷新当前惊魂数
	 */
	public void refreshText()
	{
		m_tgTextbox04.setText("当前精魂:" + "<mark c=FF0000>" + DWGameManager.getInstance().m_role.m_jinghun
				+ "</mark>");
		m_tgTextbox07.setText("当前精魂:" + "<mark c=FF0000>" + DWGameManager.getInstance().m_role.m_jinghun
				+ "</mark>");
	}

	public static boolean isNumber(String str)
	{
		Pattern pattern = Pattern.compile("[0-9]*");
		if (pattern.matcher(str).matches() == false) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "请输入数字");
		}
		return pattern.matcher(str).matches();
	}

	/** 获取宝石列表中相同宝石的总数 */
	public int getGemNum(String key)
	{
		int num = 0;
		if (m_gem_list != null && m_gem_list.length > 0) {
			for (Cell cell : m_gem_list) {
				if (cell.m_item instanceof ItemGem) {
					ItemGem gem = (ItemGem) cell.m_item;
					if (gem.m_key.equals(key)) {
						num += gem.m_num;
					}
				}
			}
		}
		return num;
	}

	/** 获取背包栏相同道具的总数 */
	public int getItemNum(String key)//TODO
	{
		int num = 0;
		Cell[] cells = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_ROLEBAG);
		if (cells != null) {
			for (Cell cell : cells) {
				if (cell.m_item instanceof Item) {
					Item gem = cell.m_item;
					if (gem.m_key.equals(key)) {
						num += gem.m_num;
					}
				}
			}
		}
		return num;
	}

	/**
	 * 合成灵石二次确认界面
	 */
	public DWFrame m_tgQRFrame01 = null;
	public DWTitle m_tgQRTitle01 = null;
	public DWButton m_tgQRButton01 = null;
	public DWButton m_tgQRButton02 = null;
	public DWGrid m_tgQRGtid01 = null;
	public DWTextbox m_tgQRTextbox01 = null;
	public DWTextbox m_tgQRTextbox02 = null;//灵石消耗
	public DWTextbox m_tgQRTextbox03 = null;//合成数量
	public DWImageBox m_tgQRImageBox01 = null;
	public DWInputBox m_tgQRInputBox01 = null;

	public DWTextbox m_tgQRTextbox04 = null;//下级灵石name

	public DWImageBox m_tgQRImageBox03 = null;
	public DWImageBox m_tgQRImageBox04 = null;

	public int hecheng_num = 1;

	public void hecheng_QueRen()
	{
		if (m_gem_list != null) {
			ItemGem gem = (ItemGem) m_gem_list[m_tgIndex04].m_item;
			final int totals = getGemNum(gem.m_key);
			hecheng_num = totals / 3;

			m_tgQRFrame01 = new DWFrame(DWGameManager.Screen_Width / 2, DWGameManager.Screen_Height / 2 + 60);
			m_tgQRTitle01 = new DWTitle("提示", m_tgQRFrame01);

			m_tgQRButton01 = new DWButton("确定", m_tgBitmap04);
			m_tgQRButton02 = new DWButton("取消", m_tgBitmap04);
			m_tgQRButton01.setDownImage(m_tgBitmap04_ax);
			m_tgQRButton02.setDownImage(m_tgBitmap04_ax);
			m_tgQRTextbox01 = new DWTextbox("合成数量：");
			m_tgQRTextbox02 = new DWTextbox("消耗灵石："
					+ "<mark c="
					+ UIBag.getNameColor(m_gem_list[m_tgIndex04].m_item.m_quality)
					+ ">"
					+ m_gem_list[m_tgIndex04].m_item.m_name
					+ "</mark>"
					+ "×"
					+ ((hecheng_num) * 3));

			m_tgQRTextbox03 = new DWTextbox("" + hecheng_num);
			m_tgQRImageBox01 = new DWImageBox(m_tgBitmap01);
			m_tgQRImageBox03 = new DWImageBox(m_fy_left);
			m_tgQRImageBox04 = new DWImageBox(m_fy_right);
			m_tgQRInputBox01 = new DWInputBox(60, m_tgQRImageBox03.getShowHeight(), m_tgQRFrame01);

			m_tgQRTextbox02.setNearAnchor(m_tgQRFrame01, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, -20, 60);
			m_tgQRTextbox01.setNearAnchor(m_tgQRTextbox02, Tools.HCENTER_BOTTOM, Tools.HCENTER_TOP, -110, -30);
			m_tgQRImageBox03.setNearAnchor(m_tgQRTextbox01, Tools.LEFT_TOP, Tools.RIGHT_TOP, 20, 0);
			m_tgQRImageBox04.setNearAnchor(m_tgQRImageBox03, Tools.LEFT_TOP, Tools.LEFT_TOP, 120, 0);
			m_tgQRGtid01.setNearAnchor(m_tgQRFrame01, Tools.LEFT_TOP, Tools.LEFT_TOP, 50, 50);
			m_tgQRInputBox01.setNearAnchor(m_tgQRImageBox03, Tools.RIGHT_TOP, Tools.RIGHT_TOP, 75, 0);
			m_tgQRTextbox03.setNearAnchor(m_tgQRImageBox03, Tools.LEFT_TOP, Tools.LEFT_TOP, 50, 0);
			m_tgQRTextbox04.setNearAnchor(m_tgQRGtid01, Tools.LEFT_TOP, Tools.RIGHT_TOP, 20, 0);
			m_tgQRImageBox01.setNearAnchor(m_tgQRTitle01, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER);
			m_tgQRImageBox01.setTouchZoomIn(20, 20);
			m_tgQRButton01.setNearAnchor(m_tgQRFrame01, Tools.LEFT_BOTTOM, Tools.LEFT_BOTTOM, 20, -20);
			m_tgQRButton02.setNearAnchor(m_tgQRFrame01, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -20, -20);

			//数量
			m_tgQRInputBox01.setText("" + (hecheng_num));
			m_tgQRInputBox01.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (isNumber(m_tgQRInputBox01.getText().toString()) == true) {
						hecheng_num = Integer.parseInt(m_tgQRInputBox01.getText().toString());
						m_tgQRInputBox01.setText("" + (hecheng_num));
						final int Number = totals / 3;
						if (hecheng_num > Number) {
							m_tgQRTextbox02.setText("消耗灵石："
									+ "<mark c="
									+ UIBag.getNameColor(m_gem_list[m_tgIndex04].m_item.m_quality)
									+ ">"
									+ m_gem_list[m_tgIndex04].m_item.m_name
									+ "</mark>"
									+ "×"
									+ ((Number * 3)));
						}
						else {
							m_tgQRTextbox02.setText("消耗灵石："
									+ "<mark c="
									+ UIBag.getNameColor(m_gem_list[m_tgIndex04].m_item.m_quality)
									+ ">"
									+ m_gem_list[m_tgIndex04].m_item.m_name
									+ "</mark>"
									+ "×"
									+ ((hecheng_num * 3)));
						}
					}
				}
			});

			m_tgQRImageBox03.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (hecheng_num > 1) {
						hecheng_num--;
					}
					else {
						hecheng_num = totals / 3;
					}
					m_tgQRInputBox01.setText("" + (hecheng_num));
					m_tgQRTextbox02.setText("消耗灵石："
							+ "<mark c="
							+ UIBag.getNameColor(m_gem_list[m_tgIndex04].m_item.m_quality)
							+ ">"
							+ m_gem_list[m_tgIndex04].m_item.m_name
							+ "</mark>"
							+ "×"
							+ ((hecheng_num * 3)));
				}
			});

			m_tgQRImageBox04.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (hecheng_num < totals / 3) {
						hecheng_num++;
					}
					else {
						hecheng_num = 1;
					}
					m_tgQRInputBox01.setText("" + (hecheng_num));
					m_tgQRTextbox02.setText("消耗灵石："
							+ "<mark c="
							+ UIBag.getNameColor(m_gem_list[m_tgIndex04].m_item.m_quality)
							+ ">"
							+ m_gem_list[m_tgIndex04].m_item.m_name
							+ "</mark>"
							+ "×"
							+ ((hecheng_num * 3)));
				}
			});

			m_tgQRImageBox01.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(m_tgQRFrame01);
				}
			});

			m_tgQRButton01.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (hecheng_num < 1) {
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "宝石数量不足");
					}
					else {
						DWGameManager.getInstance().getSendMessage().sendSynthesisGemCommand(
								m_gem_list[m_tgIndex04].m_item.m_key, (short) (hecheng_num));
					}
					DWControlsManager.getInstance().removeControl(m_tgQRFrame01);
				}
			});

			m_tgQRButton02.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					DWControlsManager.getInstance().removeControl(m_tgQRFrame01);
				}
			});

			m_tgQRFrame01.addControl(m_tgQRTitle01);
			m_tgQRFrame01.addControl(m_tgQRImageBox01);
			m_tgQRFrame01.addControl(m_tgQRButton01);
			m_tgQRFrame01.addControl(m_tgQRButton02);
			m_tgQRFrame01.addControl(m_tgQRGtid01);
			m_tgQRFrame01.addControl(m_tgQRTextbox01);
			m_tgQRFrame01.addControl(m_tgQRTextbox02);
			m_tgQRFrame01.addControl(m_tgQRTextbox04);
			m_tgQRFrame01.addControl(m_tgQRImageBox03);
			m_tgQRFrame01.addControl(m_tgQRImageBox04);
			m_tgQRFrame01.addControl(m_tgQRInputBox01);
			DWControlsManager.getInstance().addControl(m_tgQRFrame01);
		}
	}

	/**
	 * 镶嵌/取下灵石
	 * popmenu
	 */
	public void popmenu_XiangQian()
	{
		Cell cell = (Cell) m_tgGrid04.m_data;
		final ItemEquipment equip = (ItemEquipment) cell.m_item;
		if (equip.m_hasGem[m_lsIndex02] == ItemConstants.含有宝石_是) {
			final String[] m_popmenu_name = new String[] { "取下灵石" };
			m_tgPopMenu01 = new DWPopMenu(m_popmenu_name, m_tgBitmap02);
			m_tgPopMenu01.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					int m_index = m_tgPopMenu01.getIndex();
					switch (m_index) {
						case 0:
							if (m_equip_list != null) {
								final DWMessageBox mb = new DWMessageBox("取下灵石", "确定取下灵石？");
								mb.addListener(new DWListener() {

									public void OnDoubleClick()
									{

									}

									public void OnClick()
									{
										if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
											Tools.debugPrintln("取下灵石");
											Cell cell = (Cell) m_tgGrid04.m_data;
											DWGameManager.getInstance().getSendMessage().sendDownGem(
													cell.m_item.m_guid, (byte) m_lsIndex02);
											DWControlsManager.getInstance().removeControl(mb);
										}
										else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
											Tools.debugPrintln("返回");
											DWControlsManager.getInstance().removeControl(mb);
										}
									}
								});
								DWControlsManager.getInstance().addControl(mb);
							}
							break;
					}
					m_tgFrame.removeControl(m_tgPopMenu01);
				}
			});
			m_tgFrame.addControl(m_tgPopMenu01);
		}
		else {
			final String[] m_popmenu_name = new String[] { "镶嵌灵石" };
			m_tgPopMenu01 = new DWPopMenu(m_popmenu_name, m_tgBitmap02);
			m_tgPopMenu01.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					int m_index = m_tgPopMenu01.getIndex();
					switch (m_index) {
						case 0:
							if (getGemList(m_lsIndex02 + Attribute.力) != null) {
								lingshiList_Frame();
								listbox_LingShiList();
							}
							else {
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"灵石不足，商城中可以购买灵石");
							}
							break;
					}
					m_tgFrame.removeControl(m_tgPopMenu01);
				}
			});
			m_tgFrame.addControl(m_tgPopMenu01);
		}
	}

	/**
	 * 灵石列表界面
	 */
	public DWFrame m_lsFrame = null;
	public DWListbox m_listbox_LingShiList = null;
	public int m_lsIndex01 = 0;//镶嵌灵石列表下标
	public int m_lsIndex02 = -1;//灵石槽下标(-1没有选择)

	public void lingshiList_Frame()
	{
		m_lsFrame = new DWFrame(300, 300);
		m_listbox_LingShiList = new DWListbox(260, 250);
		m_listbox_LingShiList.setNearAnchor(m_lsFrame, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 30);
		m_listbox_LingShiList.setLineSpacing(10);// 设置间距
		m_listbox_LingShiList.setTouchIndex(0);// 默认选中第一个

		m_lsFrame.addControl(m_listbox_LingShiList);
		DWControlsManager.getInstance().addControl(m_lsFrame);
	}

	/**
	 * 灵石列表(镶嵌界面)
	 */
	public void listbox_LingShiList()
	{
		final Cell[] cells = getGemList(m_lsIndex02 + Attribute.力);
		if (cells != null) {
			DWListSubItem[] m_tgLSItem01 = new DWListSubItem[cells.length];
			DWTextbox[] m_tgTextbox01 = new DWTextbox[cells.length];
			DWTextbox[] m_tgTextbox02 = new DWTextbox[cells.length];
			for (int j = 0; j < cells.length; j++) {
				m_tgLSItem01[j] = new DWListSubItem();
				m_tgLSItem01[j].setAutoWideHigh(false);
				m_tgLSItem01[j].setShowWideHighUn(m_listbox_LingShiList.getShowWidth(), 30);

				m_tgTextbox01[j] = new DWTextbox("<mark c="
						+ UIBag.getNameColor(cells[j].m_item.m_quality)
						+ ">"
						+ cells[j].m_item.m_name
						+ "</mark>");
				m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 20, 0);

				m_tgTextbox02[j] = new DWTextbox("" + cells[j].m_item.m_num);
				m_tgTextbox02[j].setNearAnchor(m_tgTextbox01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 170, 0);

				if (m_listbox_LingShiList != null) {
					m_listbox_LingShiList.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							int index = m_listbox_LingShiList.getTouchIndex();
							m_lsIndex01 = index;
							String infoString = null;

							//判断当前槽和选中的宝石是否类型对应
							if (cells[m_lsIndex01].m_item != null
									&& cells[m_lsIndex01].m_item instanceof ItemGem) {
								final ItemGem gem = (ItemGem) cells[m_lsIndex01].m_item;

								if (gem.m_attrindex - Attribute.力 == m_lsIndex02) {
									if (m_tgGrid04.m_data != null && m_tgGrid04.m_data instanceof Cell) {
										Cell cell = (Cell) m_tgGrid04.m_data;
										if (cell.m_item != null && cell.m_item instanceof ItemEquipment) {
											final ItemEquipment equip = (ItemEquipment) cell.m_item;
											StringBuilder buff = new StringBuilder();
											if (equip.m_hasGem[m_lsIndex02] != ItemConstants.含有宝石_是) {
												buff.append("是否镶嵌“");
												buff.append("<mark c=");
												buff.append(UIBag.getNameColor(gem.m_quality));
												buff.append(">");
												buff.append(gem.m_name + "</mark>");
												buff.append("”？");
												infoString = buff.toString();
												buff = null;
												final DWMessageBox mb = new DWMessageBox("镶嵌提示", infoString);
												mb.addListener(new DWListener() {

													public void OnDoubleClick()
													{

													}

													public void OnClick()
													{
														if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
															Tools.debugPrintln("镶嵌灵石");
															DWControlsManager.getInstance().removeControl(m_lsFrame);
															DWGameManager.getInstance().getSendMessage()
																	.sendSetGemCommand(
																			gem.m_guid, equip.m_guid);
															DWControlsManager.getInstance().removeControl(mb);
														}
														else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
															Tools.debugPrintln("返回");
															DWControlsManager.getInstance().removeControl(mb);
														}
													}
												});
												DWControlsManager.getInstance().addControl(mb);
											}
											else {
												DWGameManager.getInstance().addSystemInfo(
														DWGameManager.SYSTEM_INFO_TYPE_B, "请先取下宝石");
											}
										}
									}
								}
								else {
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"当前宝石槽和操作宝石类型不对应");
									return;
								}
							}
						}
					});
				}
				m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
				m_tgLSItem01[j].addControls(m_tgTextbox02[j]);
				if (m_listbox_LingShiList != null) {
					m_listbox_LingShiList.addSubItem(m_tgLSItem01[j]);
				}
			}
		}
	}

	/**
	 * 装备强化属性改变值
	 */
	public void PatternChange(int needSpirit)
	{
		if (m_equip_list == null || m_equip_list[m_tgIndex02] == null || m_equip_list[m_tgIndex02].m_item == null) {
			return;
		}
		StringBuilder buff = new StringBuilder();
		ItemEquipment equip = (ItemEquipment) m_equip_list[m_tgIndex02].m_item;
		int[] attrValue = equip.m_attrValue;
		int[] attrAddValue = equip.m_attrAddValue;

		buff.append(equip.m_product_order);
		String temp = buff.toString();
		m_tgTextbox09.setText("" + equip.getProductOrder((short) equip.m_strengthenLevel));
		buff.delete(0, temp.length());

		/** 当前属性 */
		//物理攻击力
		if (attrValue[Attribute.PHY_ATTACK] > 0) {
			buff.append("物攻");
			buff.append(attrValue[Attribute.PHY_ATTACK]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(attrAddValue[Attribute.PHY_ATTACK]);
			buff.append("</mark>");
			buff.append(DWControlTools.CHANGE_ROW);
		}
		//魔法攻击力
		if (attrValue[Attribute.MAG_ATTACK] > 0) {
			buff.append("魔攻");
			buff.append(attrValue[Attribute.MAG_ATTACK]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(attrAddValue[Attribute.MAG_ATTACK]);
			buff.append("</mark>");
			buff.append(DWControlTools.CHANGE_ROW);
		}
		//物理防御力
		if (attrValue[Attribute.PHY_DEFENSE] > 0) {
			buff.append("物防");
			buff.append(attrValue[Attribute.PHY_DEFENSE]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(attrAddValue[Attribute.PHY_DEFENSE]);
			buff.append("</mark>");
			buff.append(DWControlTools.CHANGE_ROW);
		}
		//魔法防御力
		if (attrValue[Attribute.MAG_DEFENSE] > 0) {
			buff.append("法防");
			buff.append(attrValue[Attribute.MAG_DEFENSE]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(attrAddValue[Attribute.MAG_DEFENSE]);
			buff.append("</mark>");
		}
		temp = buff.toString();
		m_qh_tgTextbox31[0].setText(temp);
		buff.delete(0, temp.length());

		/** 下一级品阶 */
		buff.append(equip.getProductOrder((short) (equip.m_strengthenLevel + 1)));
		temp = buff.toString();
		m_tgTextbox10.setText(null);
		buff.delete(0, temp.length());

		/** 下一级属性 */
		//物理攻击力
		if (attrValue[Attribute.PHY_ATTACK] > 0) {
			buff.append("物攻");
			buff.append(attrValue[Attribute.PHY_ATTACK]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(m_nextStrengthenAttrAddValue[Attribute.PHY_ATTACK]);
			buff.append("</mark>");
			buff.append(DWControlTools.CHANGE_ROW);
		}
		//魔法攻击力
		if (attrValue[Attribute.MAG_ATTACK] > 0) {
			buff.append("魔攻");
			buff.append(attrValue[Attribute.MAG_ATTACK]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(m_nextStrengthenAttrAddValue[Attribute.MAG_ATTACK]);
			buff.append("</mark>");
			buff.append(DWControlTools.CHANGE_ROW);
		}
		//物理防御力
		if (attrValue[Attribute.PHY_DEFENSE] > 0) {
			buff.append("物防");
			buff.append(attrValue[Attribute.PHY_DEFENSE]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(m_nextStrengthenAttrAddValue[Attribute.PHY_DEFENSE]);
			buff.append("</mark>");
			buff.append(DWControlTools.CHANGE_ROW);
		}
		//魔法防御力
		if (attrValue[Attribute.MAG_DEFENSE] > 0) {
			buff.append("法防");
			buff.append(attrValue[Attribute.MAG_DEFENSE]);
			buff.append(" + ");
			buff.append("<mark c=00ffff>");
			buff.append(m_nextStrengthenAttrAddValue[Attribute.MAG_DEFENSE]);
			buff.append("</mark>");
		}
		temp = buff.toString();
		m_qh_tgTextbox31[4].setText(temp);
		buff.delete(0, temp.length());

		buff.append("消耗精魂：");
		buff.append(needSpirit);
		buff.append("点");
		temp = buff.toString();
		m_tgTextbox15.setText(temp);
		buff.delete(0, temp.length());

		buff = null;
	}

	/**
	 * 返回监听
	 */
	private DWListener m_back_lis = new DWListener() {

		public void OnDoubleClick()
		{

		}

		public void OnClick()
		{
			close((byte) 0);
		}
	};

	private DWFrame m_bsFrame = null;
	private DWListbox m_bsListbox01 = null;

	public void baoshi()
	{
		m_bsFrame = new DWFrame(300, 300);
		m_bsListbox01 = new DWListbox(0, 0);

		m_bsFrame.addControl(m_bsListbox01);
		DWControlsManager.getInstance().addControl(m_bsFrame);
	}

	public void open(byte index)
	{
		switch (index) {
			case 0:
				tiangong_open_state = 0;
				updata();
				tiangong();
				listbox_RongLian();
				listbox_QiangHua();
				listbox_XiangQian();
				listbox_HeCheng();
				listbox_DuanZao();
				refreshText();
				listbox_LingShiList();
				break;
			case 1:
				refreshEquipList(4);
				listbox_item();
				listbox_ShengJi();
				break;
		}
	}

	public void close(byte index)
	{
		switch (index) {
			case 0:
				delCacheList();
				repairGemList();

				refreshListbox_RongLian();
				refreshListbox_QiangHua();
				refreshListbox_XiangQian();
				refreshListbox_HeCheng();
				refreshListbox_DuanZao();

				m_equip_cache_list = null;
				m_equip_list = null;
				m_gem_list = null;
				m_gem_num = null;

				DWControlsManager.getInstance().removeControl(m_tgFrame);
				break;
			case 1:
				DWControlsManager.getInstance().removeControl(m_djFrame);
				break;
		}
		UIWindows.getInstance().m_zhanli.open_other(DWGameManager.getInstance().m_role.m_zhanli);//战力相关
	}

	public void dispose()
	{

	}

	/**
	 * 选择宝石
	 * */
	public void putGemInCell(int index, Cell cell)
	{
		if (cell != null && cell.m_item != null) {
			if (m_gem_num != null && m_gem_num[index] > 0) {
				if (--m_gem_num[index] < 1) {
					cell.m_selected = true;
				}
			}
		}
	}

	public void outGemToCell(int index, Cell cell)
	{
		if (cell != null && cell.m_item != null) {
			if (m_gem_num != null && index != -1) {
				m_gem_num[index]++;
				cell.m_selected = false;
			}
		}
	}

	/**
	 * 添加到缓存列表
	 * */
	private void addCache(Cell cell)
	{
		if (cell != null
				&& cell.m_item != null
				&& cell.m_item.m_type == ItemConstants.道具类型_装备) {
			Vector<Cell> object = m_equip_cache_list;
			Tools.debugPrintln("cell.m_item.m_name" + cell.m_item.m_name + ";cell.m_selected=" + cell.m_selected);

			if (cell.m_selected) {
				if (!object.contains(cell)) {
					object.add(cell);
				}
			}
			else {
				if (object.contains(cell)) {
					object.remove(cell);
					for (int i = 0; i < 5; i++) {
						m_tgGrid_RL01[i].m_data = null;
						m_tgGrid_RL01[i].setImage(null);
					}
					for (int i = 0; i < object.size(); i++) {
						if (m_tgGrid_RL01[i] != null) {
							m_tgGrid_RL01[i].setImage(m_tgBitmap11);
							m_tgGrid_RL01[i].m_data = object.elementAt(i).m_item;
						}
					}
				}
			}
			int size = object.size();
			Tools.debugPrintln("addCache size=" + size);
			for (Cell c : object) {
				Tools.debugPrintln("addCache c name=" + c.m_item.m_name);
			}

			if (m_tgListbox_HuanCunCao != null) {
				m_tgListbox_HuanCunCao.removeAllSubItem();
				if (object != null) {
					DWListSubItem[] m_tgLSItem01 = new DWListSubItem[size];
					DWTextbox[] m_tgTextbox01 = new DWTextbox[size];
					for (int j = 0; j < size; j++) {
						m_tgLSItem01[j] = new DWListSubItem();
						m_tgLSItem01[j].setAutoWideHigh(false);
						m_tgLSItem01[j].setShowWideHighUn(m_tgListbox_HuanCunCao.getShowWidth(), 30);
						m_tgTextbox01[j] = new DWTextbox(object.elementAt(j).m_item.m_name);
						m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 0);
						m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
						m_tgListbox_HuanCunCao.addSubItem(m_tgLSItem01[j]);
					}
					if (size == 1) {
						if (m_tgGrid_RL01[0] != null) {
							m_tgGrid_RL01[0].setImage(m_tgBitmap11);
							m_tgGrid_RL01[0].m_data = object.elementAt(0).m_item;
						}
					}
					if (size == 2) {
						if (m_tgGrid_RL01[1] != null) {
							m_tgGrid_RL01[1].setImage(m_tgBitmap11);
							m_tgGrid_RL01[1].m_data = object.elementAt(1).m_item;
						}
					}
					if (size == 3) {
						if (m_tgGrid_RL01[2] != null) {
							m_tgGrid_RL01[2].setImage(m_tgBitmap11);
							m_tgGrid_RL01[2].m_data = object.elementAt(2).m_item;
						}
					}
					if (size == 4) {
						if (m_tgGrid_RL01[3] != null) {
							m_tgGrid_RL01[3].setImage(m_tgBitmap11);
							m_tgGrid_RL01[3].m_data = object.elementAt(3).m_item;
						}
					}
					if (size == 5) {
						if (m_tgGrid_RL01[4] != null) {
							m_tgGrid_RL01[4].setImage(m_tgBitmap11);
							m_tgGrid_RL01[4].m_data = object.elementAt(4).m_item;
						}
					}
					m_tgLSItem01 = null;
					m_tgTextbox01 = null;
				}
			}
		}
	}

	/**
	 * 获取缓存列表下标
	 * @param guid
	 * @return
	 */
	public int getCacheListIndex(long guid)
	{
		int index = -1;
		Vector<Cell> vc = m_equip_cache_list;
		int size = vc.size();
		if (guid > 0 && size > 0) {
			for (int i = 0; i < size; i++) {
				Cell cell = vc.elementAt(i);
				if (cell != null && cell.m_item != null && cell.m_item.m_guid == guid) {
					index = i;
					break;
				}
			}
		}
		return index;
	}

	/**
	 * 清理缓存列表
	 */
	private void delCacheList()
	{
		Tools.debugPrintln("delCacheList");
		Vector<Cell> object = m_equip_cache_list;
		if (object == null) {
			return;
		}
		for (Cell c : object) {
			c.m_selected = false;
		}
		object.clear();
		m_tgListbox_HuanCunCao.removeAllSubItem();
	}

	private void repairGemList()
	{
		if (m_gem_list != null) {
			for (Cell c : m_gem_list) {
				c.m_selected = false;
			}
		}
	}

	/** 取出新合成的宝石，克隆一个 修改成获得的宝石数量 */
	public Cell getNewItemGem(byte type, int index, int num)
	{
		if (m_gem_list == null) {
			return null;
		}
		for (Cell cell : m_gem_list) {
			if (cell.m_column_type == type && cell.m_index == index) {
				Cell c = cell.Clone();
				c.m_item.m_num = num;
				return c;
			}
		}
		return null;
	}

	/**
	 * @exception 刷新出宝石列表
	 * */
	public void refreshGemList()
	{
		CopyOnWriteArrayList<Cell> gems = new CopyOnWriteArrayList<Cell>();
		Cell[] cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_ROLEBAG);
		if (cell != null) {
			for (Cell c : cell) {
				if (c != null && c.m_item != null) {
					if (c.m_item instanceof ItemGem) {
						gems.add(c);
					}
				}
			}
		}
		m_gem_list = null;
		int size = gems.size();
		if (size > 0) {
			m_gem_list = new Cell[size];
			m_gem_num = new int[size];
			for (int i = 0; i < size; i++) {
				Cell c = gems.get(i);
				m_gem_list[i] = c;
				m_gem_num[i] = c.m_item.m_num;
			}
		}
		gems = null;
	}

	/**
	 * @exception 根据宝石槽类型筛出宝石列表
	 * @param index 宝石槽对应的宝石属性索引
	 * */
	public Cell[] getGemList(int index)
	{
		if (m_gem_list == null || index < Attribute.力 || index > Attribute.敏) {
			return null;
		}
		CopyOnWriteArrayList<Cell> array = new CopyOnWriteArrayList<Cell>();
		for (Cell cell : m_gem_list) {
			ItemGem gem = (ItemGem) cell.m_item;
			if (gem != null && gem.m_attrindex == index) {
				array.add(cell);
			}
		}
		Cell[] gems = null;
		int size = array.size();
		if (size > 0) {
			gems = new Cell[size];
			for (int i = 0; i < size; i++) {
				gems[i] = array.get(i);
			}
		}
		array = null;
		return gems;
	}

	/**
	 * @exception 刷新出装备列表
	 * @param TabIndex 标签索引
	 * */
	public void refreshEquipList(int TabIndex)
	{
		CopyOnWriteArrayList<Cell> array = new CopyOnWriteArrayList<Cell>();
		Cell[] cell = null;
		switch (TabIndex) {
			case 0://装备熔炼分解	
				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_ROLEBAG);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							Tools.debugPrintln("c.m_item.isOperate(ItemConstants.可分解)="
									+ c.m_item.isOperate(ItemConstants.可分解) + ";name=" + c.m_item.m_name);
							if (c.m_item instanceof ItemEquipment && c.m_item.isOperate(ItemConstants.可分解)) {
								array.add(c);
							}
						}
					}
				}
				break;
			case 1://装备强化
				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_EQUIP);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							if (c.m_item instanceof ItemEquipment && c.m_item.isOperate(ItemConstants.可强化)) {
								array.add(c);
							}
						}
					}
				}

				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_ROLEBAG);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							if (c.m_item instanceof ItemEquipment && c.m_item.isOperate(ItemConstants.可强化)) {
								array.add(c);
							}
						}
					}
				}
				break;
			case 2://装备镶嵌宝石
				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_EQUIP);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							if (c.m_item instanceof ItemEquipment) {
								ItemEquipment equip = (ItemEquipment) c.m_item;
								if (equip.m_equipGemsSize > 0) {
									array.add(c);
								}
							}
						}
					}
				}

				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_ROLEBAG);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							if (c.m_item instanceof ItemEquipment) {
								ItemEquipment equip = (ItemEquipment) c.m_item;
								if (equip.m_equipGemsSize > 0) {
									array.add(c);
								}
							}
						}
					}
				}
				break;
			case 4://装备锻造
				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_EQUIP);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							if (c.m_item instanceof ItemEquipment
									&& c.m_item.m_type == ItemConstants.道具类型_装备
									&& c.m_item.m_quality >= m_EquipRarity
									&& c.m_item.m_minLevelLimit >= m_Equipminlevel) {
								if (c.m_item.m_subtype == ItemConstants.装备_武器
										|| c.m_item.m_subtype == ItemConstants.装备_头部
										|| c.m_item.m_subtype == ItemConstants.装备_上衣
										|| c.m_item.m_subtype == ItemConstants.装备_腰带
										|| c.m_item.m_subtype == ItemConstants.装备_裤子
										|| c.m_item.m_subtype == ItemConstants.装备_鞋子
										|| c.m_item.m_subtype == ItemConstants.装备_项链
										|| c.m_item.m_subtype == ItemConstants.装备_手腕
										|| c.m_item.m_subtype == ItemConstants.装备_戒指
										|| c.m_item.m_subtype == ItemConstants.装备_护符) {
									array.add(c);
								}
							}
						}
					}
				}
				cell = DWGameManager.getInstance().m_role.getCells(Cell.TYPE_COLUMN_ROLEBAG);
				if (cell != null) {
					for (Cell c : cell) {
						if (c != null && c.m_item != null) {
							if (c.m_item instanceof ItemEquipment
									&& c.m_item.m_type == ItemConstants.道具类型_装备
									&& c.m_item.m_quality >= m_EquipRarity
									&& c.m_item.m_minLevelLimit >= m_Equipminlevel) {
								if (c.m_item.m_subtype == ItemConstants.装备_武器
										|| c.m_item.m_subtype == ItemConstants.装备_头部
										|| c.m_item.m_subtype == ItemConstants.装备_上衣
										|| c.m_item.m_subtype == ItemConstants.装备_腰带
										|| c.m_item.m_subtype == ItemConstants.装备_裤子
										|| c.m_item.m_subtype == ItemConstants.装备_鞋子
										|| c.m_item.m_subtype == ItemConstants.装备_项链
										|| c.m_item.m_subtype == ItemConstants.装备_手腕
										|| c.m_item.m_subtype == ItemConstants.装备_戒指
										|| c.m_item.m_subtype == ItemConstants.装备_护符) {
									array.add(c);
								}
							}
						}
					}
				}
				break;
		}

		m_equip_list = null;
		int size = array.size();
		if (size > 0) {
			m_equip_list = new Cell[size];
			for (int i = 0; i < size; i++) {
				m_equip_list[i] = array.get(i);
				Tools.debugPrintln("m_equip_list[i] name=" + m_equip_list[i].m_item.m_name);
			}
		}
		array = null;
	}

	/**
	 * 请求分解装备后将得到的精魂数
	 * @param dis
	 * @throws IOException
	 */
	public void recvSmeltingEquip(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//0 未知错误 2有装备不符合要求
		if (state == 0) {
			return;
		}
		else if (state == 2) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "装备不符合要求,无法熔炼");
			return;
		}
		else if (state == 1) {
			int num = dis.readInt();//精魂数	
			if (m_equip_cache_list != null) {
				if (m_equip_cache_list.size() > 1) {
					final DWMessageBox mb = new DWMessageBox("提示", "熔炼“"
							+ "<mark c=" + UIBag.getNameColor(((Item) m_tgGrid_RL01[0].m_data).m_quality)
							+ ">"
							+ ((Item) m_tgGrid_RL01[0].m_data).m_name + "</mark>"
							+ "”、“"
							+ "<mark c=" + UIBag.getNameColor(((Item) m_tgGrid_RL01[1].m_data).m_quality)
							+ ">"
							+ ((Item) m_tgGrid_RL01[1].m_data).m_name + "</mark>"
							+ "”等可得到"
							+ "<mark c=FF0000>"
							+ num
							+ "</mark>"
							+ "点精魂，是否继续？");
					mb.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
								Tools.debugPrintln("熔炼惊魂");
								if (m_equip_cache_list != null) {
									DWGameManager.getInstance().getSendMessage().sendSureToSmelting();
								}
								DWControlsManager.getInstance().removeControl(mb);
							}
							else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
								Tools.debugPrintln("返回");
								DWControlsManager.getInstance().removeControl(mb);
							}
						}
					});
					DWControlsManager.getInstance().addControl(mb);
				}
				else {
					final DWMessageBox mb = new DWMessageBox("提示", "熔炼“"
							+ "<mark c=" + UIBag.getNameColor(((Item) m_tgGrid_RL01[0].m_data).m_quality)
							+ ">"
							+ ((Item) m_tgGrid_RL01[0].m_data).m_name + "</mark>"
							+ "”可得到"
							+ "<mark c=FF0000>"
							+ num
							+ "</mark>"
							+ "点精魂，是否继续？");
					mb.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
								Tools.debugPrintln("熔炼惊魂");
								if (m_equip_cache_list != null) {
									DWGameManager.getInstance().getSendMessage().sendSureToSmelting();
								}
								DWControlsManager.getInstance().removeControl(mb);
							}
							else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
								Tools.debugPrintln("返回");
								DWControlsManager.getInstance().removeControl(mb);
							}
						}
					});
					DWControlsManager.getInstance().addControl(mb);
				}
			}
		}
	}

	/**
	 * 确认分解装备
	 * @param dis
	 * @throws IOException
	 */
	public void recvSureToSmelting(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//强化是否成功 0失败 1成功
		if (state == 0) {
			return;
		}
		else if (state == 1) {
			int num = dis.readInt();//精魂数
			Tools.debugPrintln("num=" + num);
			refreshText();
			refreshEquipList(m_tabindex);
			refreshListbox_RongLian();
			listbox_RongLian();
			delCacheList();
			m_tgTextbox04.setText("当前精魂:" + "<mark c=FF0000>"
					+ DWGameManager.getInstance().m_role.m_jinghun + "</mark>");
		}
	}

	/**
	 * 精魂抽取数值
	 * @param dis
	 * @throws IOException
	 */
	public void recvExtractionSpiritNum(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();

		long jinghun_num = dis.readLong();//获得精魂数
		long gold_num = dis.readLong();//消耗金钱

		switch (state) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "未知错误");
				break;
			case 1:
				if (jinghun_num > 0) {
					final DWMessageBox mb = new DWMessageBox("提示", "自装备“"
							+ "<mark c="
							+ UIBag.getNameColor(m_equip_list[m_tgIndex02].m_item.m_quality)
							+ ">"
							+ m_equip_list[m_tgIndex02].m_item.m_name + "</mark>"
							+ "”可抽取"
							+ "<mark c=FF0000>"
							+ jinghun_num
							+ "</mark>"
							+ "点精魂，消耗金钱"
							+ "<mark c=FF0000>"
							+ gold_num
							+ "</mark>"
							+ "点，同时强化效果将消失，是否继续？");
					mb.addListener(new DWListener() {

						public void OnDoubleClick()
						{

						}

						public void OnClick()
						{
							if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
								Tools.debugPrintln("确定");
								DWGameManager.getInstance().getSendMessage().sendExtractionSpirit(
										m_equip_list[m_tgIndex02].m_item.m_guid);
								DWControlsManager.getInstance().removeControl(mb);
							}
							else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
								Tools.debugPrintln("返回");
								DWControlsManager.getInstance().removeControl(mb);
							}
						}
					});
					DWControlsManager.getInstance().addControl(mb);
				}
				else {
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "装备无精魂，无法抽取");
				}
				break;
		}
	}

	/**
	 * 精魂抽取
	 * @param dis
	 * @throws IOException
	 */
	public void recvExtractionSpirit(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//强化是否成功 0失败 1成功
		if (state == 1) {
			if (m_tgListbox_QiangHua != null) {
				m_tgListbox_QiangHua.removeAllSubItem();
			}
			refreshEquipList(m_tabindex);
			refreshText();
			listbox_QiangHua();
			m_tgTextbox09.setText(null);
			m_tgTextbox10.setText(null);
			m_tgTextbox15.setText(null);
			m_qh_tgTextbox31[0].setText(null);
			m_qh_tgTextbox31[4].setText(null);
			m_tgTextbox07.setText("当前精魂:" + "<mark c=FF0000>"
					+ DWGameManager.getInstance().m_role.m_jinghun + "</mark>");
		}
		else if (state == 2) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "游戏币不足");
		}
		else if (state == 3) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "装备无精魂,无法抽取");
		}
		dis.readLong();
	}

	/**
	 * 取下灵石
	 * @param dis
	 * @throws IOException
	 */
	public void recvDownGem(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//取下灵石是否成功 0未知错误 1成功 2背包已满
		if (state == 1) {
			refreshGemList();
			refreshEquipList(m_tabindex);
			listbox_XiangQian();
			refreshListbox_XiangQianBaoShi();
		}
		else if (state == 2) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "背包已满,请清理背包后取下灵石");
		}
		else if (state == 3)
		{
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "游戏币不足");
		}
	}

	/**
	 * 强化装备
	 * @param dis
	 * @throws IOException
	 */
	public void recvStrengThen(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//强化是否成功 0失败 1成功
		if (state == 1) {
			if (m_tgListbox_QiangHua != null) {
				m_tgListbox_QiangHua.removeAllSubItem();
			}
			refreshEquipList(m_tabindex);
			listbox_QiangHua();
			refreshText();
			Cell cell = m_equip_list[m_tgIndex02];
			ItemEquipment equip = (ItemEquipment) cell.m_item;
			if (equip.m_strengthenLevel >= equip.m_maxStrengthenLevel) {
				refreshListbox_QiangHua();
				m_tgGrid03.setImage(m_tgBitmap11);
				m_tgGrid03.m_data = cell;
				m_tgTextbox_MAXLEVEL.setShow(true);
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "当前已强化到最大等级");
			}
			else {
				DWGameManager.getInstance().getSendMessage().sendStrengthenNextLevelValues(
						(byte) m_equip_list[m_tgIndex02].m_column_type, m_equip_list[m_tgIndex02].m_index);
			}
		}
		else if (state == 2) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "此装备无法强化");
		}
		else if (state == 3) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "精魂不足，熔炼装备可获得精魂");
		}
	}

	/**
	 * 合成宝石
	 * @param dis
	 * @throws IOException
	 */
	public void recvSynthesisGem(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//合成是否成功 0失败 1成功 2背包已满
		if (state == 1) {
			if (m_tgListbox_HeCheng != null) {
				m_tgListbox_HeCheng.removeAllSubItem();
			}
			refreshGemList();
			listbox_HeCheng();
			refreshListbox_HeCheng();
			for (int i = 0; i < 3; i++) {
				m_tgGrid10[i].m_data = null;
			}

			byte type = dis.readByte();
			final int index = dis.readShort();
			int num = dis.readShort();
			m_AnimCatch = getNewItemGem(type, index, num);
			if (m_AnimCatch != null) {
				m_rdtime = RDTIME;
			}
		}
		else if (state == 2) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "背包已满,请清理背包后合成");
		}
		else if (state == 3) {
			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "宝石已是最高等级,无法继续合成");
		}
	}

	/**
	 * 镶嵌宝石
	 * @param dis
	 * @throws IOException
	 */
	public void recvSetGem(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();//镶嵌是否成功
		if (state == 1) {
			refreshListbox_XiangQianBaoShi();
			refreshEquipList(m_tabindex);
			listbox_LingShiList();
			listbox_XiangQian();
		}
		else if (state == 2) {
//			DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "");
		}
	}

	public int m_jinghun_num;

	/**
	 * 下级强化值
	 * @param dis
	 * @throws IOException
	 */
	public void recvStrengthenNextLevelValues(DataInputStream dis) throws IOException
	{
		int jinghun = dis.readInt();
		byte size = dis.readByte();
		for (int i = 0; i < size; i++) {
			int attrIndex = dis.readShort();
			int attrValue = dis.readInt();
			m_nextStrengthenAttrAddValue[attrIndex] = attrValue;
		}
		PatternChange(jinghun);
		m_jinghun_num = jinghun;
		m_tgTextbox10.setText(((ItemEquipment) m_equip_list[m_tgIndex02].m_item)
				.getProductOrder((short) (((ItemEquipment) m_equip_list[m_tgIndex02].m_item).m_strengthenLevel + 1)));
		m_tgTextbox_maxLevel
				.setText("<mark c="
						+ UIBag.getNameColor(m_equip_list[m_tgIndex02].m_item.m_quality)
						+ ">"
						+ m_equip_list[m_tgIndex02].m_item.m_name
						+ "</mark>"
						+ "最高可强至"
						+ ((ItemEquipment) m_equip_list[m_tgIndex02].m_item)
								.getProductOrder((short) ((ItemEquipment) m_equip_list[m_tgIndex02].m_item).m_maxStrengthenLevel));
	}

	/**
	 * 下级宝石属性
	 * @param dis
	 * @throws IOException
	 */
	public void recvSeeNextLevelGem(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte state = dis.readByte();
		if (state == 1) {
			final ItemGem item = (ItemGem) Item.recvItemFormServer(dis);
			m_tgQRGtid01 = new DWGrid(m_tgBitmap11);
			m_tgQRGtid01.m_data = item;
			m_tgQRTextbox04 = new DWTextbox("<mark c="
					+ UIBag.getNameColor(item.m_quality)
					+ ">"
					+ item.m_name + "</mark>"
					+ DWControlTools.CHANGE_ROW
					+ Attribute.ATTRIBUTE_NAME[item.m_attrindex]
					+ ": +"
					+ item.m_attrvalue);
			m_tgQRGtid01.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					UIWindows.getInstance().m_bag.showItemMessage(item);
				}
			});
			hecheng_QueRen();
			m_tgGrid09.addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					if (m_tgGrid09.m_data != null) {
						UIWindows.getInstance().m_bag.showItemMessage(item);
					}
				}
			});
		}
	}

	/**
	 * 装备锻造
	 * @param dis
	 * @throws IOException
	 */
	public void recvEquipmentForge(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_天工);
		byte starLevel = dis.readByte();//读取装备星级
		((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv = starLevel;
		if (m_tgFrame != null) {
			m_dzTextbox_TiShiBHF.setShow(false);
			m_dzGrid_BaoHu.setImage(m_dzBitmap_Suo);
			m_dzGrid_BaoHu.setTouch(false);
			m_animBox_daoju.setShow(false);
			m_animBox_star.setShow(false);
			m_dzBaoHuFu_index = false;
			m_dzGrid_BaoHu.m_data = null;

			Cell cell01 = null;
			if (duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount > 0) {
				cell01 = DWGameManager.getInstance().m_role
						.getCellByKeyForRoleBagColumn(duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1key);

				if (cell01 != null && cell01.m_item != null) {
					if (cell01.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount) {
						m_dzTextbox_num02
								.setText(getItemNum(cell01.m_item.m_key)
										+ "/"
										+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount);
						m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
					}
					else {
						m_dzTextbox_num02
								.setText("<mark c=FF0000>"
										+ getItemNum(cell01.m_item.m_key)
										+ "</mark>"
										+ "/"
										+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount);
						m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
					}
				}
				else {
					m_dzTextbox_num02
							.setText("<mark c=FF0000>0</mark>/"
									+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount);
					m_dzTextbox_num02.setNearAnchor(m_dzGrid_CaiLiao02, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
				}
			}

			Cell cell02 = null;
			if (duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount > 0) {
				cell02 = DWGameManager.getInstance().m_role
						.getCellByKeyForRoleBagColumn(duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2key);

				if (cell02 != null && cell02.m_item != null) {
					if (cell02.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount) {
						m_dzTextbox_num01
								.setText(getItemNum(cell02.m_item.m_key)
										+ "/"
										+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount);
						m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
					}
					else {
						m_dzTextbox_num01
								.setText("<mark c=FF0000>"
//										+ cell02.m_item.m_num
										+ getItemNum(cell02.m_item.m_key)
										+ "</mark>"
										+ "/"
										+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount);
						m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
					}
				}
				else {
					m_dzTextbox_num01
							.setText("<mark c=FF0000>0</mark>/"
									+ duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount);
					m_dzTextbox_num01.setNearAnchor(m_dzGrid_CaiLiao01, Tools.HCENTER_TOP, Tools.HCENTER_BOTTOM);
				}
			}
			if (cell01 != null && cell01.m_item != null && cell02 != null && cell02.m_item != null) {
				if (cell01.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item1keycount
						&&
						cell02.m_item.m_num >= duanZaos[((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv].m_Item2keycount) {
					m_animBox_duanzao.setShow(true);
					if ((((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv) < m_Maxstarlevel
							&& (((ItemEquipment) (m_equip_list[m_dzIndex_DuanZao].m_item)).m_attrLv) > 0) {
						m_dzGrid_BaoHu.setImage(m_tgBitmap11);
						m_dzGrid_BaoHu.setTouch(true);
						m_animBox_daoju.setShow(true);
						m_dzTextbox_TiShiBHF.setShow(true);
					}
				}
			}
		}
	}

	/** 允许锻造的装备最小等级 */
	public int m_Equipminlevel;
	/** 允许锻造的装备最低品质 */
	public byte m_EquipRarity;
	/** 保护石的key */
	public String m_Stonekey;
	/** 最高星级 */
	public int m_Maxstarlevel;
	/** 多少级以上不能再使用保护石 */
	public byte m_Nobaohulevel;
	/** 装备锻造等级数量 */
	public byte m_open_size;
	/** 锻造集合 */
	public DuanZao duanZaos[] = null;;
	/** 锻造系统开启等级 */
	public int m_dzOpenLevel;

	/**
	 * loading接收锻造属性
	 * @param dis
	 * @throws IOException
	 */
	public void recvEquipmentOpen(DataInputStream dis) throws IOException //TODO 装备锻造接收方法
	{
		int Equipminlevel = dis.readInt();//允许锻造的装备最小等级
		m_Equipminlevel = Equipminlevel;
		byte EquipRarity = dis.readByte();//允许锻造的装备最低品质
		m_EquipRarity = EquipRarity;
		String Stonekey = dis.readUTF();//保护石的key
		m_Stonekey = Stonekey;
		int Maxstarlevel = dis.readInt();//最高星级
		m_Maxstarlevel = Maxstarlevel;
		byte Nobaohulevel = dis.readByte();//多少级以上不能再使用保护石
		m_Nobaohulevel = Nobaohulevel;
		byte Size = dis.readByte();//数量
		m_open_size = Size;
		duanZaos = new DuanZao[Size];
		for (int i = 0; i < Size; i++) {
			DuanZao dz = new DuanZao();
			dz.setStarlevel(dis.readByte());//星级
			dz.setSuccess(dis.readInt());//成功率
			dz.setItem1key(dis.readUTF());//道具a的key
			dz.setItem1keycount(dis.readInt());//道具a的数量
			dz.setItem1icon(dis.readShort());//icon1
			dz.setItem2key(dis.readUTF());//道具b的key
			dz.setItem2keycount(dis.readInt());//道具b的数量
			dz.setItem2icon(dis.readShort());//icon2
			dz.setUpattr(dis.readUTF());//提升点数
			dz.setMoney(dis.readInt());//消耗金钱
			dz.setDownlevel(dis.readByte());//失败降到级别
			duanZaos[dz.getStarlevel() - 1] = dz;
		}
		int openlevel = dis.readInt();//开启锻造等级
		m_dzOpenLevel = openlevel;
	}

	/**
	 * @exception 获得列表对应的控件对象
	 * @param 标签
	 * @param 道具ID
	 * @return DWListSubItem
	 * */
	public DWListSubItem getListSubItem(int index, long guid)
	{
		DWListbox box = null;
		Cell[] list = null;
		switch (index) {
			case 0://装备熔炼
				box = m_tgListbox_RongLianCao;
				list = m_equip_list;
				break;
			case 1://强化
				box = m_tgListbox_QiangHua;
				list = m_equip_list;
				break;
			case 2://镶嵌
				box = m_tgListbox_XiangQian;
				list = m_equip_list;
				break;
			case 3://合成
				box = m_tgListbox_HeCheng;
				list = m_gem_list;
				break;
		}
		if (box == null || list == null) {
			return null;
		}
		int size = list.length;
		int subIndex = -1;
		for (int i = 0; i < size; i++) {
			Item item = list[i].m_item;
			if (item != null && item.m_guid == guid) {
				subIndex = i;
				item = null;
				break;
			}
		}
		if (subIndex == -1 || subIndex > box.getSubItemSize() - 1) {
			return null;
		}
		list = null;
		return box.getListSubItem(subIndex);
	}

	public void logic()
	{
		CreatNewGemsAnim();

		DuanZao_Anim();
	}

	public void CreatNewGemsAnim()
	{
		if (m_AnimCatch != null) {
			if (m_rdtime > 0) {
				m_rdtime--;
			}
			else {
				m_rdtime = RDTIME;
				if (m_AnimIndex < m_tgBitmap_DH.length - 1) {
					m_AnimIndex++;
					m_tgImageBox_DH_HC.setImage(m_tgBitmap_DH[m_AnimIndex]);
					m_tgImageBox_DH_HC.setShow(true);

				}
				else {
					m_AnimIndex = -1;
					m_rdtime = -1;
					m_tgImageBox_DH_HC.setShow(false);
					m_tgGrid09.m_data = m_AnimCatch;
					m_AnimCatch = null;
				}
			}
		}
	}

	/**
	 * 锻造界面动画
	 */
	public void DuanZao_Anim()
	{
		if (m_dzHengYi_x) {
			if (m_dzGrid_x >= 0 && m_dzGrid_x <= m_dzImageBox_JianTou.getShowWidth()) {
				m_dzGrid_ZhuangBei.setNearAnchor(m_dzGrid_Copy, Tools.LEFT_TOP, Tools.LEFT_TOP, -m_dzGrid_x, 0);
				m_dzGrid_x += 5;
			}
			else if (m_dzGrid_x > m_dzImageBox_JianTou.getShowWidth()) {
				m_dzGrid_ZhuangBei_next.setShow(true);
//				m_dzImageBox_JianTou.setShow(true);
				m_animBox_jiantou.setShow(true);
				m_dzHengYi_x = false;
			}
		}
	}

	/**
	 * 使用装备提升券后的装备列表
	 */
	public DWFrame m_djFrame = null;
	public DWTitle m_djTitle = null;
	public DWImageBox m_djGuanBi = null;
	public DWBackground m_djBackground = null;
	public DWListbox m_djListbox = null;
	public long m_baohufu_guid = 0;

	public void listbox_item()
	{
		m_djFrame = new DWFrame(DWGameManager.Screen_Width / 3, DWGameManager.Screen_Height / 2 + 60);
		m_djTitle = new DWTitle("装备升级", m_djFrame);

		m_djGuanBi = new DWImageBox(m_tgBitmap01);
		m_djGuanBi.setNearAnchor(m_djTitle, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER);
		m_djGuanBi.setTouchZoomIn(20, 20);
		m_djGuanBi.addListener(new DWListener() {

			public void OnDoubleClick()
			{

			}

			public void OnClick()
			{
				close((byte) 1);
			}
		});

		m_djBackground = new DWBackground(m_djFrame.getShowWidth() - 20, m_djFrame.getShowHeight() - 30);
		m_djBackground.setNearAnchor(m_djFrame, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM, 0, -10);

		m_djListbox = new DWListbox(m_djBackground.getShowWidth(), m_djBackground.getShowHeight() - 10);
		m_djListbox.setNearAnchor(m_djBackground, Tools.HCENTER_BOTTOM, Tools.HCENTER_BOTTOM);
		m_djListbox.setLineSpacing(10);

		m_djFrame.addControl(m_djBackground);
		m_djFrame.addControl(m_djTitle);
		m_djFrame.addControl(m_djGuanBi);
		m_djFrame.addControl(m_djListbox);
		DWControlsManager.getInstance().addControl(m_djFrame);
	}

	/**
	 * 装备锻造列表
	 */
	public void listbox_ShengJi()
	{
		if (m_equip_list != null) {
			final DWListSubItem[] m_tgLSItem01 = new DWListSubItem[m_equip_list.length];
			DWTextbox[] m_tgTextbox01 = new DWTextbox[m_equip_list.length];

			for (int j = 0; j < m_equip_list.length; j++) {
				m_tgLSItem01[j] = new DWListSubItem();
				m_tgLSItem01[j].setAutoWideHigh(false);
				m_tgLSItem01[j].setShowWideHighUn(m_djListbox.getShowWidth(), 30);

				m_tgTextbox01[j] = new DWTextbox("<mark c=" + UIBag.getNameColor(m_equip_list[j].m_item.m_quality)
						+ ">" + m_equip_list[j].m_item.m_name + "</mark>");
				m_tgTextbox01[j].setNearAnchor(m_tgLSItem01[j], Tools.LEFT_TOP, Tools.LEFT_TOP, 30, 0);

				m_djListbox.addListener(new DWListener() {

					public void OnDoubleClick()
					{

					}

					public void OnClick()
					{
						int index = m_djListbox.getTouchIndex();
						m_dzIndex_DuanZao = index;

						if (((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv < m_Maxstarlevel) {
							final DWMessageBox mb = new DWMessageBox("提示",
									"确定将"
											+ "<mark c="
											+ UIBag.getNameColor(m_equip_list[m_dzIndex_DuanZao].m_item.m_quality)
											+ ">"
											+ m_equip_list[m_dzIndex_DuanZao].m_item.m_name
											+ "</mark>"
											+ "提升到"
											+ (((ItemEquipment) m_equip_list[m_dzIndex_DuanZao].m_item).m_attrLv + 1)
											+ "级？");
							mb.addListener(new DWListener() {

								public void OnDoubleClick()
								{

								}

								public void OnClick()
								{
									if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
										DWGameManager.getInstance().getSendMessage().sendEquipmentQuan(
												m_equip_list[m_dzIndex_DuanZao].m_item.m_guid, m_baohufu_guid);
										close((byte) 1);
									}
									else if (mb.getResult() == DWMessageBox.SOFTKEY_BACK) {

									}
									DWControlsManager.getInstance().removeControl(mb);
								}
							});
							DWControlsManager.getInstance().addControl(mb);
						}
						else {
							DWGameManager.getInstance().addSystemInfo(
									DWGameManager.SYSTEM_INFO_TYPE_B, "“" +
											m_equip_list[m_dzIndex_DuanZao].m_item.m_name
											+ "”已强化到最高等级");
						}
					}
				});
				m_tgLSItem01[j].addControls(m_tgTextbox01[j]);
				m_djListbox.addSubItem(m_tgLSItem01[j]);
			}
		}
	}
}
